Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.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
Ios 执行UIActionSheet操作';在不同的视图控制器上?_Ios_Iphone_Objective C_Uiviewcontroller_Uiactionsheet - Fatal编程技术网

Ios 执行UIActionSheet操作';在不同的视图控制器上?

Ios 执行UIActionSheet操作';在不同的视图控制器上?,ios,iphone,objective-c,uiviewcontroller,uiactionsheet,Ios,Iphone,Objective C,Uiviewcontroller,Uiactionsheet,我的应用程序中有一个滑出菜单,它有一个按钮,可以显示UIActionSheet。此滑出菜单仅部分覆盖了您以前使用的任何视图控制器 - (void)cameraButtonPushed:(UIButton *)sender { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Create String" delegate:self cancelButtonTitle:@"Cancel" destr

我的应用程序中有一个滑出菜单,它有一个按钮,可以显示UIActionSheet。此滑出菜单仅部分覆盖了您以前使用的任何视图控制器

- (void)cameraButtonPushed:(UIButton *)sender
{   
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Create String" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from Library", nil];

    [actionSheet showInView:[UIApplication sharedApplication].keyWindow];

    //[actionSheet showInView:self.parentViewController.view];
}
正如你所看到的,我尝试了两种方式来显示动作表,它们看起来都是一样的

我遇到的问题是,动作表按钮实际工作。它显示在父视图控制器(您所在的视图控制器)中,但如果我按下任何按钮,它们都不起作用

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {
        EditVC *newEditVC = [self.storyboard instantiateViewControllerWithIdentifier:@"editVC"];
        [editVC setHidesBottomBarWhenPushed:YES];
        [self.parentViewController.navigationController pushViewController:newEditVC animated:YES];

      //[self.navigationController pushViewController:newEditVC animated:YES];
    } else if (buttonIndex == 1) {
        EditVC *newEditVC = [self.storyboard instantiateViewControllerWithIdentifier:@"editVC"];
        [editVC setHidesBottomBarWhenPushed:YES];
        [self.parentViewController.navigationController pushViewController:newEditVC animated:YES];

      //[self.navigationController pushViewController:newEditVC animated:YES];
    }
}
上述两种方法都位于按下按钮的同一菜单视图控制器中。我放了一些断点来测试它,并调用了ActionSheet委托方法。if语句工作正常,但新的VC没有按应有的方式推送到导航控制器上。它只是越过那些线,什么也没发生。我也尝试过这样设置:父视图控制器中也有
actionSheet:clickedbutonnatindex:
方法,但没有调用该方法

我相信这与设置一个不合适的委托人的行动表有关,但我不确定


如何从一个视图控制器调用此操作表、显示它并在另一个视图控制器中执行操作?我有它出现在正确的VC,但行动的不工作

使用断点调试时,请检查self.parentViewController.navigationController,它可能为零。@chandu你说得对。self.parentViewController.navigationController和self.navigation控制器都返回nil。我应该怎么做才能访问父级的导航控制器?你的应用程序窗口的rootViewController是navigationController吗?@chandu是的,但是当我使用代码访问rootViewController时,它返回为nil。我使用[UIApplication sharedApplication].keyWindow,然后通过它访问rootViewController。从该调用中获取rootVC返回为nil?怎么可能没有rootView,您可以在github或bitbucket中共享您的代码?