UIAlertView silently crashes when button is clicked

0

I have a view which that has MKMapView as its subview. Since the space I have for map isn't big, I blocked all interactions with the map, like scrolling, scaling etc. Instead when user taps the map (actually he taps an invisible button placed on the map) I open Apple Maps with the location set. This works fine.

    MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:zoomLocation addressDictionary:nil];
    self.mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
    self.mapItem.name = @"name of the place";

    UIButton *overlayButton = [UIButton buttonWithType:UIButtonTypeCustom];
    overlayButton.frame = self.bounds;
    overlayButton.backgroundColor = [UIColor clearColor];
    overlayButton.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    [overlayButton addTarget:self action:@selector(didTapOverlayButton) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:overlayButton];

And didTapOverlayButton caused this to be executed:

[self.mapItem openInMapsWithLaunchOptions:nil];

Now I don't want to kick the user out of my app and open another without warning him about it, so I added a UIAlertView. And now didTapOverlayButton looks like this:

- (void)didTapOverlayButton {
    UIAlertView *mapOpenAlert = [[UIAlertView alloc] initWithTitle:nil message:@"Do you want to open maps to see this location's details?" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
    [mapOpenAlert show];
}

Now when I click one of the buttons, my application will turn off (if I click "YES" it will open the maps, but still turn off). There is no error shown, nothing in logs, no memory warnings. self (the delegate of alert view) isn't released, my class is declared as conforming to the UIAlertViewDelegate protocol.

My delegate's method:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex != alertView.cancelButtonIndex) {
        [self openExternalMap];
    }
}

- (void)openExternalMap {
    [self.mapItem openInMapsWithLaunchOptions:nil];
}

Tested on both iOS 6 and 7.

Edit: I'm getting this in the console:

Feb 20 16:14:31 iPhone-Devices com.apple.debugserver-300.2[6048] : 1 +0.000000 sec [17a0/1307]: error: ::read ( -1, 0x3169ec, 18446744069414585344 ) => -1 err = Bad file descriptor (0x00000009)

Feb 20 16:14:31 iPhone-Devices com.apple.debugserver-300.2[6048] : Exiting.

ios
objective-c
mapkit
uialertview
mkmapitem
asked on Stack Overflow Feb 20, 2014 by johnyu • edited Feb 21, 2014 by johnyu

1 Answer

1

I'm pretty sure this is a bug in iOS7 - I noticed it during the beta and it looks like it has never been fixed. I would suggest filing a bug report at Apple :

https://developer.apple.com/bug-reporting/

answered on Stack Overflow Feb 20, 2014 by GuybrushThreepwood

User contributions licensed under CC BY-SA 3.0