Skip to content

Instantly share code, notes, and snippets.

View Proper-Job's full-sized avatar

Moritz Pfeiffer Proper-Job

  • Basel, Switzerland
View GitHub Profile
@Proper-Job
Proper-Job / gist:e11cca67e77285566d4d
Created May 27, 2014 14:18
Restrict MKMapView to specific region
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
if (!self.manuallyChangingMap) {
BOOL updateRegion = NO;
MKCoordinateRegion restrictedRegion = [self restrictedRegion];
if ((mapView.region.span.latitudeDelta > restrictedRegion.span.latitudeDelta * 4) || (mapView.region.span.longitudeDelta > restrictedRegion.span.longitudeDelta * 4) ) {
updateRegion = YES;
}
if (fabs(mapView.region.center.latitude - restrictedRegion.center.latitude) > restrictedRegion.span.latitudeDelta) {
@Proper-Job
Proper-Job / gist:56d22b36714e3339be05
Last active August 29, 2015 14:05
Activity call to startService() effectively cancels prior Service call to stopSelf()
public class BindingActivity extends Activity {
private ServiceConnection boundStartedServiceConnection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.binding_activity);
boundStartedServiceConnection = new ServiceConnection() {