PushViewController 和 popToRootViewController
我的应用程序正在使用pushViewController以模态方式显示导航控制器
[navigationController pushViewController:_viewController animated:YES];
导航控制器已完成按钮
UIButton* backButton = [UIButton buttonWithType:101];
[backButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside];
[backButton setTitle:@"Done" forState:UIControlStateNormal];
UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backItem;
[backItem release];
当按下完成按钮时我希望它应该导航回主窗口
-(void) dismissView: (id)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
//[self.navigationController popToViewController:_viewController animated:YES];
}
但是当我按下完成按钮时什么也没有发生。这是为什么?
My application is using pushViewController to show the navigation controller modally
[navigationController pushViewController:_viewController animated:YES];
Navigation Controller has done button
UIButton* backButton = [UIButton buttonWithType:101];
[backButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside];
[backButton setTitle:@"Done" forState:UIControlStateNormal];
UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backItem;
[backItem release];
When done button is pressed I want that it should navigate back to main window
-(void) dismissView: (id)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
//[self.navigationController popToViewController:_viewController animated:YES];
}
But when I press on done button nothing happens. Why is that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请在您的 dissmissView 中 NSLog
或使用断点调试应用程序。
Please NSLog in your dissmissView
or debug the app with break point.
我很确定“101”无效,
您应该使用以下 UIButtonType 值之一
,而不是测试您的代码,在您的missView中放入一些 NSLog:以查看它是否被调用
im quite sure "101" is invalid
you should use one of the following UIButtonType values
other than that test your code put some NSLog in your dismissView: to see if it gets called