APPdelegatew文件
#import "TestAppDelegate.h"
#import "FirstViewController.h"@implementation TestAppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];// Override point for customization after application launch.self.window.backgroundColor = [UIColor whiteColor];[self.window makeKeyAndVisible];//导航视图控制器//1创建导航控制器(UINavigationController)FirstViewController *firstVC = [[FirstViewController alloc]init];//创建导航控制器时 要制定一个视图控制器(rootViewController)UINavigationController *naviVC = [[UINavigationController alloc]initWithRootViewController:firstVC];//把导航控制器指定为window的根视图控制器(windoe的rootViewController)self.window.rootViewController = naviVC;//内存管理[naviVC release];[firstVC release];[_window release];return YES;}
- (void)dealloc
{[_window release];[super dealloc];
}- (void)applicationWillResignActive:(UIApplication *)application
{// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}- (void)applicationDidEnterBackground:(UIApplication *)application
{// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}- (void)applicationWillEnterForeground:(UIApplication *)application
{// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}- (void)applicationDidBecomeActive:(UIApplication *)application
{// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}- (void)applicationWillTerminate:(UIApplication *)application
{// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
FirstViewController文件
#import "FirstViewController.h"
#import "SecondViewController.h"@interface FirstViewController ()@end@implementation FirstViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];if (self) {// Custom initializationself.title = @"皮城女警";}return self;
}- (void)viewDidLoad
{[super viewDidLoad];// Do any additional setup after loading the view.self.view.backgroundColor = [UIColor cyanColor];//按钮用于推出新的视图控制器UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];[button setTitle:@"让子弹飞一会吧" forState:UIControlStateNormal];[button addTarget:self action:@selector(buttonclicked:) forControlEvents:UIControlEventTouchUpInside];button.frame = CGRectMake(20, 120, 280, 50);button.backgroundColor = [UIColor whiteColor];[self.view addSubview:button];//navigationBar的设置//1.获得当前的navigationbar//透明设置 YES/NO[self.navigationController.navigationBar setTranslucent:NO];//2.设置颜色[self.navigationController.navigationBar setBarTintColor:[UIColor yellowColor]];//3.隐藏navigationbar  YES/NO[self.navigationController setNavigationBarHidden:NO];//navigationItm设置//1.获取navigationItm//设置标题// self.navigationItem.title = @"冰霜女巫";//设置标题位置的view//self.navigationItem.titleView = button;//设置navigation左侧的按钮(UIBarButtonItm)self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(barButtonAction:)];self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:(self) action:@selector(barButtonRight:)];// UIBarButtonItem *barButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(barButtonAction:)];// UIBarButtonItem *barButton1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(barButtonAction:)];
//    //将多个barButtonItem添加到数组
//    NSArray *arr = [NSArray arrayWithObjects:barButton1, barButton2, nil];
//    //将数组里面的所有item显示到navigationBar上
//    self.navigationItem.leftBarButtonItems  = arr;}
- (void)barButtonRight:(UIBarButtonItem *)bar
{SecondViewController *secVC = [[SecondViewController alloc]init];[self.navigationController pushViewController:secVC animated:YES];[secVC release];
}- (void)barButtonAction:(UIBarButtonItem *)bar
{NSLog(@"黎明就在眼前");}
- (void)buttonclicked:(UIButton *)button
{//推出第二个视图控制器//1.创建第二个视图控制器SecondViewController *secondVC = [[SecondViewController alloc]init];//2.推出//利用viewController的属性  获得当前的导航控制器//调用pushViewController:animated:方法 推出新的viewController[self.navigationController pushViewController:secondVC animated:YES];//内存管理[secondVC release];
}- (void)didReceiveMemoryWarning
{[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}/*
#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{// Get the new view controller using [segue destinationViewController].// Pass the selected object to the new view controller.
}
*/@end
SecondViewController文件
#import "SecondViewController.h"
#import "ThirdViewController.h"@interface SecondViewController ()@end@implementation SecondViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];if (self) {// Custom initializationself.title = @"曙光女神";}return self;
}- (void)viewDidLoad
{[super viewDidLoad];// Do any additional setup after loading the view.self.view.backgroundColor = [UIColor redColor];UIButton *abutton = [UIButton buttonWithType:UIButtonTypeSystem];[abutton setTitle:@"太阳照耀着你" forState:UIControlStateNormal];[abutton addTarget:self action:@selector(abuttonclicked:) forControlEvents:UIControlEventTouchUpInside];abutton.frame = CGRectMake(22, 120, 280, 50);abutton.backgroundColor = [UIColor whiteColor];[self.view addSubview:abutton];
}
- (void)abuttonclicked:(UIButton *)button
{ThirdViewController *thirdVC = [[ThirdViewController alloc]init];[self.navigationController pushViewController:thirdVC animated:YES];[thirdVC release];}- (void)didReceiveMemoryWarning
{[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}/*
#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{// Get the new view controller using [segue destinationViewController].// Pass the selected object to the new view controller.
}
*/@end

IOS导航控制器的随堂笔记相关推荐

  1. iOS导航控制器和Segues

    In this tutorial we'll discuss and implement iOS UI Navigation Controller. It's another common UI el ...

  2. iOS 导航控制器、导航条、导航项、控制器的关系

    常见的APP的页面结构,分为两个横向和纵向两个维度,最为经典的就是横向维度采用UITabBarController,纵向维度采用UINavigationController.当然,横向维度还可以使用U ...

  3. iOS导航控制器——UINavigationController使用详解

    一.概述 UINavigationController用来管理视图控制器,在多视图控制器中常用.它以栈的形式管理视图控制器,管理视图控制器个数理论上不受限制(实际受内存限制),push和pop方法来弹 ...

  4. IOS 多层级路由导航控制器 NavigationControoller 实现路由切换

    IOS 导航控制器分为多层级导航控制器naviagtionController 和平行分栏控制器 UITabBar(底部切换栏).IOS导航控制器是什么呢?其实就是我们web的路由切换功能,只不过在a ...

  5. ios学习笔记3--导航控制器详解

    前言: 导航控制器和标签控制器是ios中常用的两个控件.因此,特意写一篇文章记录一下,自己对导航控制器的理解,持续更新中. 导航条UINavigationBar介绍 容器UINavigationIte ...

  6. IOS开发入门(11)-导航控制器(1)

    IOS开发入门(11)-导航控制器I:层级结构和标签 前言:(直接从书上抄的) 大多数应用程序是由主视图导出多个屏幕,并且通常情况下实现屏幕切换的方法还不止一种.我们需要一种方式来实现用户在应用程序内 ...

  7. iOS开发UI篇—多控制器和导航控制器简单介绍

    iOS开发UI篇-多控制器和导航控制器简单介绍 一.多控制器 一个iOS的app很少只由一个控制器组成,除非这个app极其简单.当app中有多个控制器的时候,我们就需要对这些控制器进行管理 有多个vi ...

  8. 【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记20 Multiple MVCs 多MVC模式、NavigationController导航控制器...

    上一话讲完了小人脸Demo,我们也了解了MVC,那么这一话我们来把Demo复杂化,看看多个MVC之间是如何协同工作的.回顾一下我们之前讲过的多个MVC的情况. IOS提供了一些控制器,它们的视图是其他 ...

  9. iOS 中导航控制器全屏向右滑动返回上一界面

    在iOS中,导航控制器默认就自带了侧滑功能,当用户在界面的左边(左边边缘)滑动的时候,才会有侧滑功能.但是我们往往在开发的过程中需要在屏幕的任意位置滑动,都需要返回到上一个界面. 多说无意,直接看代码 ...

最新文章

  1. UML中的六种关系的比较与学习
  2. MT6580热设计要求
  3. 什么是迭代器,JS如何实现迭代器
  4. Iphone表视图的简单操作
  5. [概率][lca][dfs][树形dp] Jzoj P4225 宝藏
  6. MFC DoDataExchange()绑定技术
  7. 面向对象,局部变量和成员变量
  8. linux cisco路由器,Linux用dynamic模拟cisco路由器
  9. 【Linux入门指北】第六篇 Linux常用的开发工具
  10. Python+VSCode+Git【转】
  11. go语言 gin框架中集成zap日志库
  12. 生活鸡汤---送给女人和男人的
  13. linux ping不通自动关机脚本,服务器断电自动关机bat脚本
  14. AcitveMQ--HelloWorld
  15. 从头开始实现一个小型spring框架——手写Spring之集成Tomcat服务器
  16. 第四章 微信公众号开发之验证消息的确来自微信服务器
  17. Javascript是什么?java是什么?JavaScript与Java有什么关系?
  18. 手写字体识别 --MNIST数据集
  19. 【分享论坛】最新steam离线账号/单机资源/优质软件/资源问题解答
  20. vc获取n卡编号_NVIDIA n卡各主要显卡核心代号

热门文章

  1. 同学们,长路漫漫伴你闯
  2. c语言 队列---->链表实现
  3. 关于我被室友忽悠去下载appium那档子事
  4. qt显示html富文本图片,Qt QLabel显示图片 动画 富文本
  5. Excel VBA 学习笔记13:单元格的格式
  6. 从头到尾把事做成,要有多难?
  7. shell脚本7.15
  8. Lucene in Action(简体中文版)
  9. 百趣代谢组学实验室分享-细胞培养避坑指南
  10. 暗调时尚科幻杂志科技封面人物效果