2014-08-27 94 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