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為下個頁面返回按鈕的名字。
這就是SecondView了。
3、添加segmentedController
在nav bar這樣的效果是如何實現的呢?
這就是segmentedController。
3.1在RootViewController.m的viewDidLoad添加如下代碼:
4、自定義backBarButtonItem
左上角的返回上級View的barButtonitem的名字是上級目錄的Title,如果title或者適合做button的名字,怎么辦呢?我們可以自己定義
代碼如下:
6、自定義title
UINavigationController的title可以用別view替代,比如用UIButton UILable等,下面我用UIButton.
在SecondViewController.m中添加下面如下。
下篇文件講下Navigation 的Toobar如何顯示和如何自己定義。
下篇:
IOS學習之UINavigationController詳解與使用(三)ToolBarhttp://blog.csdn.net/duxinfeng2010/article/details/7707072
例子代碼:https://github.com/schelling/YcDemo
原博客連接地址http://blog.csdn.net/totogo2010/article/details/7682433
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。