Iphone UINavigation控制器上的“完成”按钮未导航回
当我单击“完成”按钮时,应该导航回mainviewcontroller的地方没有发生任何事情Iphone UINavigation控制器上的“完成”按钮未导航回,iphone,ios,uinavigationcontroller,uibarbuttonitem,Iphone,Ios,Uinavigationcontroller,Uibarbuttonitem,当我单击“完成”按钮时,应该导航回mainviewcontroller的地方没有发生任何事情 UIBarButtonItem * button = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self
UIBarButtonItem * button = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(dismissView:)] autorelease];
[[self navigationItem] setRightBarButtonItem:button];
-(void)dismissView: (id)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
它应该导航回mainviewcontroller。但它什么也没做。有什么问题吗
谢谢您的帮助。当前的ViewController是否已推送到导航堆栈上
self.navigationController
仅当视图控制器在其堆栈中时返回导航控制器。如果找不到导航控制器,则此属性为nil
调试并检查它是否为非零。加入一些断点,看看故障点在哪里。dismissView:甚至被呼叫?您的代码的哪一部分是
[[self-navigationItem]setRightBarButtonItem:button]代码>?请添加更多信息以获取更多上下文。如何输入要弹出的控制器?是你推的还是模态视图控制器?您是否将“完成”按钮连接到IB中的该方法?