Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa touch UIActionSheet无效参数不满足:视图!=无_Cocoa Touch_Uiview_Uiviewcontroller_Uinavigationcontroller_Uiactionsheet - Fatal编程技术网

Cocoa touch UIActionSheet无效参数不满足:视图!=无

Cocoa touch UIActionSheet无效参数不满足:视图!=无,cocoa-touch,uiview,uiviewcontroller,uinavigationcontroller,uiactionsheet,Cocoa Touch,Uiview,Uiviewcontroller,Uinavigationcontroller,Uiactionsheet,在导航堆栈上弹出一些视图控制器后,我出现了这个错误,最后我通过操作表问了一个问题。我得到的错误参数不符合view!=nil,这让我抓狂,因为在调用操作表之前检查时,它不是一个nil值 if (self.view != nil) { NSLog(@"view is not nil"); } UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"title" delegate

在导航堆栈上弹出一些视图控制器后,我出现了这个错误,最后我通过操作表问了一个问题。我得到的错误参数不符合
view!=nil
,这让我抓狂,因为在调用操作表之前检查时,它不是一个
nil

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

每次弹出后,我都必须对[self-performSelector:withObject:afterDelay:1.]进行一次选择,我猜这与视图的状态有关。需要显示中。

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

showInView给了我无效参数,但不满足:view!=无也有例外。。所以我尝试了
[self.view addSubview action sheet]


showInView应该在viewDidLoad之后调用,因此如果添加[actionSheet showInView:self.view];在ViewDidDisplay中,它不会崩溃。

此错误发生在我在Xcode 4.6.2中的单元测试中,当时它碰到了一行应该显示UIActionSheet的代码。在旧版本的Xcode中没有出现这种情况。我认为这是因为一个类似的问题——在单元测试期间没有任何视图可以呈现给您

为了解决这个问题,我编写了一个测试来修改底层数据,然后对其进行测试,而不是提交一个操作表,然后选择一个按钮,然后向苹果提交一份bug报告