iOS UI基础-11.0 UINavigationController
导航控制器
UINavigationController的使用步骤
- 初始化UINavigationController
- 设置UIWindow的rootViewController为UINavigationController
- 根据具体情况,通过push方法添加对应个数的子控制器
使用push方法能将某个控制器压入栈
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated;
使用pop方法可以移除控制器
- (UIViewController *)popViewControllerAnimated:(BOOL)animated;
- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated;
销毁一个控制器
[self dismissViewControllerAnimated:YES completion:nil];
或者采用循环的方法,听说这种方法挺有效
for (UIViewController *controller in self.navigationController.viewControllers) {if ([controller isKindOfClass:[你要跳转到的Controller class]]) {[self.navigationController popToViewController:controller animated:YES];}
}
导航栏
@property(nonatomic,retain) UIBarButtonItem *backBarButtonItem;
@property(nonatomic,retain) UIView *titleView;
@property(nonatomic,copy) NSString *title;
@property(nonatomic,retain) UIBarButtonItem *leftBarButtonItem;
@property(nonatomic,retain) UIBarButtonItem *rightBarButtonItem;
另外技巧
在View中获取当前导航栏
// 假设 App 结构是 Root -> TabBar -> Navigation -> ViewControllerUITabBarController *tabBarControler = (id)[UIApplication.sharedApplication.delegate.window.rootViewController;UINavigationController *navigationController = tabBarControler.selectedViewController;
转载于:https://www.cnblogs.com/jys509/p/4825437.html
iOS UI基础-11.0 UINavigationController相关推荐
- iOS UI基础-6.0 UIActionSheet的使用
UIActionSheet是在iOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件. 使用 1.需要实现UIActionSheetDelegate 协议 @interface NJWisdom ...
- iOS UI基础-7.0 UIScrollView
概述 移动设备的屏幕大小是极其有限的,因此直接展示在用户眼前的内容也相当有限.当展示的内容较多,超出一个屏幕时,用户可通过滚动手势来查看屏幕以外的内容,普通的UIView不具备滚动功能,不能显示过多的 ...
- pod install 时遇到 Automatically assigning platform `iOS` with version `11.0` on target XXX......
pod install的时候遇到的问题: [!] CDN: trunk Repo update failed - 2 error(s): CDN: trunk URL couldn't be down ...
- iOS UI基础-4.1应用程序管理 字典转Model
用模型取代字典 使用字典的坏处 一般情况下,设置数据和取出数据都使用"字符串类型的key",编写这些key时,编辑器没有智能提示,需要手敲 dict[@"name&quo ...
- iOS开发UI基础—手写控件,frame,center和bounds属性
iOS开发UI基础-手写控件,frame,center和bounds属性 一.手写控件 1.手写控件的步骤 (1)使用相应的控件类创建控件对象 (2)设置该控件的各种属性 (3)添加控件到视图中 (4 ...
- IOS开发基础之UI基础的团购源码完整版本
IOS开发基础之UI基础的团购源码完整版本 // // ViewController.m // 17-团购案例 // // Created by 鲁军 on 2021/2/4. //#import & ...
- IOS开发之UI基础LOL英雄展示-15
IOS开发之UI基础LOL英雄展示-15 // // ViewController.m // 15-英雄展示-单组数据 // // Created by 鲁军 on 2021/2/3. //#impo ...
- IOS开发基础之UI的喜马拉雅的项目-10
IOS开发基础之UI的喜马拉雅的项目-10 // // ViewController.m // 10-喜马拉雅 // // Created by 鲁军 on 2021/2/2. //#import & ...
- IOS UI开发基础之超级猜图完整版本-08
IOS UI开发基础之超级猜图完整版本-08 // // ViewController.m // 09-超级猜图 // // Created by 鲁军 on 2021/1/31. //#import ...
最新文章
- flash玩转cookie
- es6 --- 自制迭代器
- Xcode缓存数据清除
- l2-006 树的遍历
- Python 命令行库的大乱
- zephir 编译php,使用Zephir来快速编写高性能PHP二进制拓展
- 用java做登录界面_求用JAVA编写的登陆界面!
- Oracle统计信息锁,oracle 由于impdp 引起的表统计信息被锁 ORA-20005: object statistics are locked...
- VC:CString用法整理
- Git和Github详细教程
- mysql 查出数据后插入新建表
- mysql创建数据库sql语句_创建数据库的SQL语句:mysql数据库
- 阿里云盘——新的屠龙勇士?
- webgl 地球_使用WebGL和JavaScript构建地球
- MAC通过HDMI转VGA转接头连接显示器
- android节日接口,节假日api及其整合
- dns找不到服务器,“找不到服务器或DNS错误”,如何调整?
- HDU 2197 本源串
- rsync下行同步和inotify实时同步部署
- Centos8 开启Telnet服务