我有一个视图控制器,我从其中启动UIAlertController
单击按钮。下面是我的代码:
- (IBAction)playOnlineURL:(UIButton *)sender {
[self launchPlayURLAlert];
}
- (void) launchPlayURLAlert{
NSString *defaultURLString = @“MY URL”;
UIAlertController * alertController = [UIAlertController alertControllerWithTitle: @"Play Online URL"
message: @"Enter the URL"
preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"Enter URL";
textField.text = defaultURLString;
textField.textColor = [UIColor blueColor];
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.borderStyle = UITextBorderStyleRoundedRect;
}];
[alertController addAction:[UIAlertAction actionWithTitle:@"Play" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *url = [[NSURL alloc] initWithString:[[alertController textFields] firstObject].text];
VideoPlayerVC *videoController = [[VideoPlayerVC alloc] initWithNibName:@"VideoPlayerVC"
bundle:nil
url:url];
[self presentViewController:videoController animated:YES completion:nil];
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
[self presentViewController:alertController animated:YES completion:nil];
}
But, my app is crashing giving EXC_BAD_ACCESS.
经过尝试很多事情后,我终于改变了
[self presentViewController:alertController animated:YES completion:nil];
to
[self presentViewController:alertController animated:NO completion:nil];
在上面的代码中,它开始工作。
所以,我的问题是为什么要通过动画为 YES造成崩溃吗?
另外,需要注意的一个有趣的点是,如果我重置整个模拟器并以“是”动画运行应用程序,那么它在前几次运行中都可以工作。 X 运行一段时间后,它开始崩溃。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)