UIActionSheet Invalid parameter not satisfying: view != nil

☆樱花仙子☆ 提交于 2019-12-04 21:23:57

Very likely that the view you are attempting to display the UIActionSheet in is not attached to the window yet. Try calling showInView after the view is attached to a window. Assuming the above code is in view controller implementation, try calling it in viewDidLoad instead of loadView.

I had to to a [self performSelector: withObject: afterDelay:1.] After each pop, I'm guessing it has to do something with the state of the view. In needs to be displayed.

showInView was giving me Invalid parameter not satisfying: view != nil exception too.. so i tried [self.view addSubview action sheet];

showInView should be called after viewDidLoad so if add [actionSheet showInView:self.view]; in viewDidAppear , it won't crash..

This error occurred in my unit tests in Xcode 4.6.2 when it hit a line that should present a UIActionSheet. It did not occur in older versions of Xcode. I think it is because of a similar issue - there is no view to present to during unit testing.

I worked around it by writing my test to modify the underlying data and then test it, rather than present an action sheet and then select a button, and submitted a bug report to Apple.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!