2014-11-21 46 views
1

我有一个UITableview。当选择一行时,会弹出一个UIActionSheet。要添加UIActionSheet我用UIActionSheet上的iOS App craches

[actionSheet showFromRect:cell.bounds inView:cell animated:NO]; 

一切工作正常,我可以选择在UIActionView项目,我可以挖掘之外,它消失。但是当它消失时(从点击外部或选择一个项目),我快速点击其他东西,例如背景,应用程序崩溃与以下消息:

-[UIActionSheet _dismissForTappedIndex:]: message sent to deallocated instance 0x173796d0 

我猜应用weants驳回片,但它已被释放之前?感谢您的任何帮助。

+0

你是使用Xcode 6编译iOS8吗?你在打什么代表方法?例如,您是否使用clickedButtonAtIndex方法? – 2014-11-21 15:18:54

+0

是的,我。我试过** willDismissWithButtonIndex **和** didDismissWithButtonIndex **,但没有成功。 – Sven 2014-11-21 15:57:27

回答

0

尽量保留对UIActionSheet的引用。例如,让它成为一个属性。这个错误意味着ARC正在释放对象太快.IF错误停止发生,那就是问题所在。

+0

非常感谢你....这是解决方案。 – Sven 2014-11-21 16:18:11

0

如果您使用'clickedButtonAtIndex'委托方法来捕获水龙头,在iOS8下我也遇到了崩溃,虽然它在更改为didDismissButtonAtIndex时已经修复。

我有一个与UIAlertView类似的崩溃,所以这可能也是UIActionSheet的情况。

在iOS8上,请clickedButtonAtIndexdidDismissWithButtonIndex

改变这一行本

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex (NSInteger)buttonIndex { 

改变你的委托方法来

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ 

你应该找到这样便解决了崩溃。

我希望这会有所帮助。

+0

问题是关于'UIActionSheet',而不是'UIAlertView'。 – rmaddy 2014-11-21 15:26:04

+0

@rmaddy对不起,我的错误,读得太快。我会检查并更新回答 – 2014-11-21 15:27:17

+0

谢谢,但** willDismissWithButtonIndex **和** didDismissWithButtonIndex **都不成功:-(。 – Sven 2014-11-21 15:56:12