【问题标题】:UIActionSheet _button valueforKey Crash in iOS8UIActionSheet _button valueforKey Crash in iOS8
【发布时间】:2014-08-27 16:17:48
【问题描述】:

iOS 8 中,添加图像到 UIActionSheet's _button valueForKey. 的以下代码崩溃

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.'

我该如何解决?

【问题讨论】:

  • 你有什么东西吗??

标签: ios ios8 uiactionsheet


【解决方案1】:

你所做的从来都是不合法的。您不能直接修改操作表的界面。如果您的代码曾经通过 App Store Guardians,那只是疏忽。

使用自定义的演示转换动画来制作一个看起来像操作表(或者实际上,看起来不像操作表)的视图控制器视图。在 iOS 7 和 8 中制作部分覆盖屏幕的呈现视图控制器视图既简单又合法。

【讨论】:

  • 在 iOS 7 中,上面的代码很好。只发生在 iOS8 中。
  • 听我说的。这不好。 iOS 8 已经(正确地)关闭了允许你做一些你不应该做的事情的漏洞。有一种简单而正确的方法可以做到这一点。我已经告诉你它是什么了。接受这个事实并继续前进。
  • 我什至写了一篇文章来描述如何做到这一点,以及为 iOS 8 修改的可下载代码:radar.oreilly.com/2014/01/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-03
  • 1970-01-01
  • 1970-01-01
  • 2012-10-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多