单击按钮时,UIAlertView会静默崩溃

时间:2014-02-20 12:31:56

标签: ios objective-c mapkit uialertview mkmapitem

我有一个视图,其中MKMapView作为其子视图。由于我用于地图的空间不大,我阻止了与地图的所有交互,例如滚动,缩放等。相反,当用户点击地图时(实际上他点击地图上放置的隐形按钮)我打开Apple Maps with the map位置设置。这很好。

    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];

didTapOverlayButton导致执行此操作:

[self.mapItem openInMapsWithLaunchOptions:nil];

现在我不想让用户退出我的应用程序并打开另一个而不会警告他,所以我添加了一个UIAlertView。现在didTapOverlayButton看起来像这样:

- (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];
}

现在当我点击其中一个按钮时,我的应用程序将关闭(如果我点击“是”它将打开地图,但仍然关闭)。没有显示错误,日志中没有任何内容,没有内存警告。 self(警报视图的委托)未发布,我的类被声明为符合UIAlertViewDelegate协议。

我的代表的方法:

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

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

在iOS 6和7上都进行了测试。

编辑: 我在控制台中得到了这个:

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 =错误的文件描述符(0x00000009)

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

1 个答案:

答案 0 :(得分:1)

我很确定这是iOS7中的一个错误 - 我在测试期间注意到了它,看起来它从未被修复过。我建议在Apple提交一份错误报告:

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

相关问题