UIActionSheet showInview方法导致第二次崩溃应用程序 [英] UIActionSheet showInview method cause crashed the app in second time
本文介绍了UIActionSheet showInview方法导致第二次崩溃应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用UIActionSheet来选择选项。相同的代码在iOS 7中运行良好,但问题出现在iOS 8中。
I am using UIActionSheet to choose options. The same code work fine in iOS 7 but the problem arise in iOS 8.
actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose an option" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:Nil otherButtonTitles:@"Option1", @"Option2", @"Option2", nil];
在IBAction上,我使用以下代码显示操作表。
On a IBAction I am using the below code to show action sheet.
[actionSheet showInView:[self view]];
这是第一次正常工作。但是,由于EXE_BAD_ACCESS
It's work fine for the first time. But in second time the app got crashed due to EXE_BAD_ACCESS
推荐答案
从 @TonyMkenu启发
的评论我在下面做了以及它的工作。
Inspiring from @TonyMkenu
's comment I do below and it's work.
完成dismissViewControllerAnimated后,我发布了操作表。
On completion of dismissViewControllerAnimated I released the action sheet.
[self dismissViewControllerAnimated:YES completion:^{
actionSheet =nil;
}];
在致电之前,我每次都分配了行动表。
And before calling I allocated the action sheet every time.
if(! actionSheet)
actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose an option" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:Nil otherButtonTitles:@"Option1", @"Option2", @"Option2", nil];
[actionSheet showInView:[self view]];
这篇关于UIActionSheet showInview方法导致第二次崩溃应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文