本文主要是介绍IOS开发(18)IOS UINavigationController类使用常见问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1 常见问题
1 隐藏返回按钮
//隐藏返回按钮[self.navigationItem setHidesBackButton:YES];
2 导航添加右侧按钮
//设置UINavigationController 右侧按钮UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed: @"scanf_24.png"] style:UIBarButtonItemStyleDone target:self action:@selector(onClick)];self.navigationItem.rightBarButtonItem = anotherButton;
3 返回显示上一个控制器
- (IBAction)cancelClick:(id)sender {[self.navigationController popViewControllerAnimated:YES];}
4 返回显示最顶层控制器
- (IBAction)cancelClick:(id)sender {[self.navigationController popToRootViewControllerAnimated:YES];}
5 返回显示任意层级控制器
- (IBAction)backClick:(id)sender {[self.navigationController popToViewController: [self.navigationController.viewControllers objectAtIndex: 1] animated: YES];//[self.navgationController.viewControllers objectAtIndex:i] animations:YES];}
6 隐藏导航条
- (IBAction)registerClick:(id)sender {WITRegisterViewController *registerC = [[WITRegisterViewController alloc] init];NSLog(@"qqq5");[self.navigationController pushViewController: registerC animated:YES]; }- (IBAction)resetPasswordClick:(id)sender {[self dismissViewControllerAnimated: YES completion: nil];}
这篇关于IOS开发(18)IOS UINavigationController类使用常见问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!