ios - UIActionSheet block View Controller dealloc

标签 ios objective-c memory-leaks uiactionsheet ios8.1

当在我的 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/

相关文章:

objective-c - UIPickerView 中不同大小的多个组件/列

ios - 如何从核心蓝牙设备读取信息

iphone - 如何将 CGPoint 添加到 NSMutableArray?

c - 尽管内存已被释放,Valgrind 仍检测到内存泄漏

javascript - _.bind 期间 lodash.js 中可能存在内存泄漏

ios - 如何隐藏 .numberPad 键盘上的字母?

ios - 关闭当前模态视图 Controller curl 效果并打开 MFMailComposeViewController

ios - 无法将类型 'NSTaggedPointerString' 的值转换为数组

c++ - 在 Cocos2d-x 中,CC_SAFE_DELETE 和 CC_SAFE_RELEASE_NULL 有什么区别?

ios - UIView 动画无法调整 View 大小