UIActionSheet无效的参数不满足

UIActionSheet无效的参数不满足

本文介绍了UIActionSheet无效的参数不满足:view!= nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在导航堆栈上弹出一些视图控制器之后得到这个错误,最后我通过一个操作表提出问题。我得到错误参数不满足 view!= nil ,这驱动我疯了,因为它事实不是一个 nil

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];


推荐答案

很可能你试图显示的视图UIActionSheet中未附加到窗口。在视图附加到窗口后尝试调用showInView。假设上面的代码在视图控制器实现,尝试调用它在viewDidLoad而不是loadView。

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.

这篇关于UIActionSheet无效的参数不满足:view!= nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 01:29