I'm getting this error after popping some view controllers on a navigation stack, and at the end I get to ask a question through an action sheet. I'm getting the error parameter not satisfying view != nil
, which drives me crazy because it-so facto is not a nil
value when I check before calling the action sheet.
if (self.view != nil) {
NSLog(@"view is not nil");
}
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"title" delegate:nil cancelButtonTitle:@"cancel" destructiveButtonTitle:@"destructive" otherButtonTitles:nil];
[actionSheet showInView:self.view];
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.