UINavigationController使用的一些技巧
来源:互联网 发布:看门狗2低配优化补丁 编辑:程序博客网 时间:2024/05/20 22:00
1,创建并使用一个UINavigationController
- UINavigationController *aNav = [[UINavigationController alloc] init];
- UIViewController *aView = [[UIView alloc] initWithNibName: (*xib文件名*)];[aNav pushViewController:aView animated:NO];
2,设置导航栏的左右按钮:
我说过,设置导航栏的按钮并不是去设置导航栏本身,而是当时被导航的视图控制器,比如我们对aView作设置。
设置其标题:
- aView.title = @"标题"; //配置一个按钮
- IBarButtonItem *callModalViewButton = [[UIBarButtonItem alloc] initWithTitle:@"经文"
- style:UIBarButtonItemStyleBordered
- target:self
- action:@selector(callModalList)];
- self.navigationItem.leftBarButtonItem = callModalViewButton;
- [callModalViewButton release]; //由于本地视图会retain它,所以我们可以release了
可以看到,还是很简单的嘛。
3,其他常用方法和属性:- self.navigationItem.leftBarButtonItem //左边栏项目本地视图
- self.navigationItem.rightBarButtonItem //右边栏项目本地视图.
- self.navigationItem.backBarButtonItem //后退栏项目本地视图.
- self.navigationItem.hidesBackButton //隐藏后退按钮(YES or NO)
- [self.tableView reloadData];
后来发现原来用了UINavigationController后,viewWillAppear方法是没有效果的,要用UINavigationControllerDelegate的
- – navigationController:willShowViewController:animated:
1. 设置代理类 nav.delegate = self;
2. 代理类实现UINavigationControllerDelegate Protocol
3. 在代理类中添加– navigationController:willShowViewController:animated:方法
如:
- - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
- [self.myTableView reloadData];
- }
- pushViewController:viewController animated:BOOL
(加载视图控制器)– 添加指定的视图控制器并予以显示,后接:是否动画显示
- popViewControllerAnimated:BOOL
- popToViewController:viewController animated:BOOL
- popToRootViewControllerAnimated:BOOL
- setNavigationBarHidden:BOOL animated:BOOL
现pushViewController:animated:的不同页面转换特效
1. 首先要明确的是,不使用pushViewController的默认动画,所以在调用这个函数时,要将animated设置为NO.
2. 使用普通的来CATransition实现转换效果,代码如下:
- CATransition *animation = [CATransition animation];
- [animation setDuration:0.3];
- [animation setType: kCATransitionMoveIn];
- [animation setSubtype: kCATransitionFromTop];
- [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
- [self.navigationController pushViewController:m_poseAddIssueViewController animated:NO];
- [self.navigationController.view.layer addAnimation:animation forKey:nil];
0 0
- UINavigationController使用的一些技巧
- UINavigationController使用的一些技巧
- UINavigationController使用的一些技巧
- UINavigationController使用的一些技巧
- UINavigationController使用的一些技巧
- iphone UINavigationController使用的一些技巧
- UINavigationController的使用技巧
- UINavigationController的一些总结
- 21.UINavigationController和UINavigationBar的使用小技巧
- UINavigationController的使用
- UINavigationController的使用
- UiNavigationController的使用
- UINavigationController,UITableview的使用
- UINavigationController的使用
- UINavigationController 的使用
- IOS的UINavigationController使用
- js 使用技巧的一些技巧
- Jasperreport的一些使用技巧
- 笔记本电脑搜索不到无线wifi处理办法
- STL 优先队列
- C++中拷贝构造函数
- ubuntu下交叉编译环境构建
- Linux进程间通信——套接字(二)
- UINavigationController使用的一些技巧
- Android入门:Activity四种启动模式
- A010:tail 命令详解-日志文件
- 三角网法计算土方量
- makefile 教程
- 如何给Actionbar添加动画(支持2.3)
- 关于ARM的22个常用概念
- [后缀数组+思路] hdu 4416 Good Article Good sentence
- POJ 3525 二分答案,推进多边形和半平面交