专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 移动开发

IOS学习之UINavigationController详解与施用(二)页面切换和segmentedController

发布时间:2010-05-30 05:30:26 文章来源:www.iduyao.cn 采编人员:星星草
IOS学习之UINavigationController详解与使用(二)页面切换和segmentedController

IOS学习之UINavigationController详解与使用(一)添加UIBarButtonItem是上篇,我们接着讲UINavigationController的重要作用,页面的管理和切换。

1、RootView 跳到SecondView

首先我们需要新一个View。新建SecondView,按住Command键然后按N,弹出新建页面,我们新建SecondView


2、为Button 添加点击事件,实现跳转

在RootViewController.xib中和RootViewController.h文件建立连接



在RootViewController.m中实现代码,alloc一个SecondViewController,用pushViewController到navigationController中去,并为

SecondViewController这是title为    secondView.title =@"Second View"; 默认情况下,titie为下个页面返回按钮的名字。

这是点击GotoSecondView 按钮,出现

这就是SecondView了。


3、添加segmentedController

在nav bar这样的效果是如何实现的呢?


这就是segmentedController。

3.1在RootViewController.m的viewDidLoad添加如下代码:


3.2[segmentedController addTarget:selfaction:的实现

这样就能响应鸡翅和排骨按钮了

4、自定义backBarButtonItem

左上角的返回上级View的barButtonitem的名字是上级目录的Title,如果title或者适合做button的名字,怎么办呢?我们可以自己定义

代码如下:

效果:

6、自定义title

UINavigationController的title可以用别view替代,比如用UIButton UILable等,下面我用UIButton.

在SecondViewController.m中添加下面如下。

运行程序,goto secondView,运行效果



下篇文件讲下Navigation 的Toobar如何显示和如何自己定义。
 下篇:

IOS学习之UINavigationController详解与使用(三)ToolBar


例子代码:https://github.com/schelling/YcDemo

著作权声明:本文由http://blog.csdn.net/totogo2010/原创,欢迎转载分享。请尊重作者劳动,转载时保留该声明和作者博客链接,谢谢





友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: