Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.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
Objective c 从uialertview按钮打开uiviewcontroller_Objective C_Ios_Uiviewcontroller_Uiwebview_Uialertview - Fatal编程技术网

Objective c 从uialertview按钮打开uiviewcontroller

Objective c 从uialertview按钮打开uiviewcontroller,objective-c,ios,uiviewcontroller,uiwebview,uialertview,Objective C,Ios,Uiviewcontroller,Uiwebview,Uialertview,如果按下UIALertView按钮,我想打开UIViewController 我有密码。但是,未打开uiviewcontroller:( 我确信uialertview工作得很好,uiviewcontroller的代码也很好(从其他地方调用时也能工作) 有什么帮助吗 谢谢 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) //Y

如果按下UIALertView按钮,我想打开UIViewController

我有密码。但是,未打开uiviewcontroller:(

我确信uialertview工作得很好,uiviewcontroller的代码也很好(从其他地方调用时也能工作)

有什么帮助吗

谢谢

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0) //Yes, Sign Me Up!
{
    NSLog(@"0");
    ViewerWebController *web = [[ViewerWebController alloc] initWithURL:[NSURL URLWithString:@"http://www.funimation.com/"]];
    [web setShowToolbar:YES];
    [self.navigationController pushViewController:web animated:YES];
    [web release];

}
else if (buttonIndex == 1) //Remove from List
{
    NSLog(@"1");
    [[NSUserDefaults standardUserDefaults] setBool:false forKey:@"subscribeButtonOption"];
    [_tableView reloadData];
}
else if (buttonIndex == 2) //"Maybe Later" 
{
    NSLog(@"2");
}
}
这可能行得通

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
  // the user clicked one of the OK/Cancel buttons
  if (buttonIndex == 0)
  {
      YourRootNavigationController *navController = [YourRootNavigationController sharedInstance]; // singleton
      [navController pushViewController:YOUR_CONTROLLER animated:YES];
  }
  else
  {
    NSLog(@"cancel");
  }
}

警报视图没有导航控制器。您需要保留对要将视图控制器推送到的导航控制器的引用。

请改用

前者在UIAlertView从屏幕层次结构中删除后调用,后者在UIAlertView仍在屏幕上时调用。在屏幕上,UIAlertView会改变应用程序的性质;这意味着在尝试将视图推送到导航控制器时会发生不好的情况


这种对点击按钮索引的误用似乎是互联网上常见的错误信息和堆栈溢出。这让我沮丧了好几个小时。

显然有些部分工作不正常:)请发布代码。您是将视图控制器推到导航控制器上还是以模式显示视图控制器?您使用什么来“打开”UIViewController?如果没有看到一些代码片段,很难判断出什么是错误的。您能否检查导航控制器在尝试推送它时是否已初始化?NSLog(@“%@”,self.navigationController);我希望视图控制器成为导航控制器堆栈的一部分。那不可能吗?我该怎么做?任何提示?添加
NSLog(@“导航控制器为%@”,self.navigationController)就在调用pushViewController的上方。