当在我的 View Controller 中时,我触摸按钮启动这个简单的代码
- (IBAction)tapOnButton:(UIButton *)sender
{
UIActionSheet *act = [[UIActionSheet alloc] initWithTitle:@"test" delegate:self cancelButtonTitle:@"aa" destructiveButtonTitle:@"bb" otherButtonTitles:@"cc", nil];
[act showFromRect:CGRectMake(50, 50, 100, 100) inView:self.view animated:YES];
}
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
}
}
我在屏幕上看到一个操作表,点击操作表的任何按钮即可关闭。
当我运行解雇时,我的 View Controller 未执行 dealloc 。 如果您不触摸按钮并且不打开操作表,则 dealloc 会起作用。
是一个足够大的问题。有人在搞事情吗?
我使用的是 iOS 8.1.3
最佳答案
我在 iOS 8 iPad 中使用已弃用的 UIActionSheet 时遇到了同样的问题。使用iPhone(iOS 7和iOS 8)和iOS 7 iPad,无法重现该问题。
目前我测试过的唯一可行的解决方案是使用 UIAlertController 在 iOS 8 中呈现操作表。如果您使用 UIAlertController, View Controller 将被正确释放。
关于ios - UIActionSheet block View Controller dealloc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28218432/