2014-08-27 96 views
0

iOS 8,以下代码坠毁添加图片到UIActionSheet's_buttonvalueForKey.UIActionSheet _button valueforKey崩溃在iOS8上

UIActionSheet *action = [[UIActionSheet alloc ] initWithTitle:@"Choose Action!" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Start Auto Scroll", nil]; 

[[[action valueForKey:@"_buttons"] objectAtIndex:0] setImage:[UIImage imageNamed:@"autoScroll.png"] forState:UIControlStateNormal]; 

[action showInView:self.view]; 

崩溃日志是

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIActionSheet 0x7ff6d8c61030> valueForUndefinedKey:]: this class is not key value coding-compliant for the key _buttons.' 

我该如何解决呢?

+0

您得到的任何东西? – 2014-09-19 08:34:31

回答

5

你在做什么从来都不合法。您不能直接修改操作表的界面。如果你的代码是通过App Store监护人的,那只是一个疏忽。

使用自定义演示文稿过渡动画来制作视图控制器视图,看起来像一个动作表(或的确,看起来不像动作表)。在iOS 7和8中制作部分覆盖屏幕的呈现视图控制器视图非常简单且合法。

+0

在iOS 7中,上面的代码很好。只发生在iOS8。 – 2014-08-27 16:26:30

+1

听我说的是什么。这不好。 iOS 8已经(正确)关闭了漏洞,允许你做一些你本不该做的事情。有一个简单而正确的方法来做到这一点。我已经告诉过你它是什么。接受这一事实并继续前进。 – matt 2014-08-27 16:27:39

+0

我甚至写过一篇文章描述如何做到这一点,以及已经修改为iOS 8的可下载代码:http://radar.oreilly.com/2014/01/transcending-uialertview-on-ios-7。 HTML – matt 2014-09-24 15:56:42