iOS工作记录六 :导航栏(基础实用)
来源:互联网 发布:地平线3pc版 优化差 编辑:程序博客网 时间:2024/05/21 09:09
镔哥哥认为直接代码,会理解更好
//
// ViewController.m
// 导航栏
//
// Created by apple on 14/11/20.
// Copyright (c) 2014年 huweibin.com.cn. All rights reserved.
//
#import "ViewController.h"
#import "secondViewViewController.h"//跳转到第二个控制窗口
@interface ViewController ()
- (void)viewDidLoad {
[superviewDidLoad];
NSLog(@"-->viewDidLoad");
self.view.backgroundColor = [UIColorblueColor];
#pragma mark-创建导航栏
//创建导航栏
UINavigationBar *navbar = [[UINavigationBaralloc]initWithFrame:CGRectMake(0,0, 320, 64)];
//创建一个导航栏集合
UINavigationItem *navItem = [[UINavigationItemalloc]initWithTitle:@"师傅来了"];
//在这个集合Item中添加标题,按钮
//style:设置按钮的风格,一共有三种选择
//action:@selector:设置按钮的点击事件
UIBarButtonItem *leftButton = [[UIBarButtonItemalloc]initWithTitle:@"左边的师妹"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(clickLeftButton)];
//创建一个右边按钮
UIBarButtonItem *rightButton = [[UIBarButtonItemalloc] initWithTitle:@"右边的师姐"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(clickRightButton)];
//把左右两个按钮添加到导航栏集合中去
[navItem setLeftBarButtonItem:leftButton];
[navItem setRightBarButtonItem:rightButton];
//把导航栏集合添加到导航栏中,设置动画关闭
[navbar pushNavigationItem:navItem animated:NO];
[self.viewaddSubview:navbar];
// Do any additional setup after loading the view, typically from a nib.
}
#import "secondViewViewController.h"
@interface secondViewViewController ()
@end
@implementation secondViewViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.view.backgroundColor = [UIColorredColor];
// Do any additional setup after loading the view.
#pragma mark-创建导航栏
//创建导航栏
UINavigationBar *navbar = [[UINavigationBaralloc]initWithFrame:CGRectMake(0,0, 320, 64)];
//创建一个导航栏集合
UINavigationItem *navItem = [[UINavigationItemalloc]initWithTitle:@"贱人来了"];
//在这个集合Item中添加标题,按钮
//style:设置按钮的风格,一共有三种选择
//action:@selector:设置按钮的点击事件
UIBarButtonItem *leftButton = [[UIBarButtonItemalloc]initWithTitle:@"返回师妹"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(clickLeftButton)];
//创建一个右边按钮
UIBarButtonItem *rightButton = [[UIBarButtonItemalloc] initWithTitle:@"右边"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(clickRightButton)];
//把左右两个按钮添加到导航栏集合中去
[navItem setLeftBarButtonItem:leftButton];
[navItem setRightBarButtonItem:rightButton];
//把导航栏集合添加到导航栏中,设置动画关闭
[navbar pushNavigationItem:navItemanimated:NO];
[self.viewaddSubview:navbar];
}
-(void) clickRightButton
{
[selfshowDialog:@"点击了导航栏右边按钮"];
}
-(void) clickLeftButton
{
[selfshowDialog:@"点击了导航栏左边按钮"];
[selfdismissViewControllerAnimated:YEScompletion:nil];
}
-(void)showDialog:(NSString *)str
{
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"这是一个对话框"message:str delegate:selfcancelButtonTitle:@"确定"otherButtonTitles: nil];
[alert show];
}
- iOS工作记录六 :导航栏(基础实用)
- IOS学习(六)导航视图控制器
- iOS 导航栏的一些使用属性记录(备忘)
- iOS工作记录7 :ios控件加载图片,plist,懒加载,序列帧动画,添加动画效果(实用例子)
- java学习记录----java基础(六)
- 导航栏实用设置
- IOS基础-导航栏控制器 UINavigationController
- iOS开发实用知识点记录(持续更新)
- iOS开发基础学习笔记——导航控制器2->导航栏(UINavigationBar)/工具栏(toolBar)/导航元素按钮(UINavigationItem)
- 记录我的新工作(六)
- 黑马程序员-iOS基础-Objective-C基础(六)
- Git基础:工作流程 + 实用命令
- iOS 开发基础常用控件介绍总结-----导航栏UINavigationController
- iOS基础控件-导航栏控制器UINavigationController的UINavigationBar导航条
- iOS自定义导航栏-导航栏联动(一)
- iOS自定义导航栏-导航栏联动(二)
- [Win8]Windows8开发笔记(六):页面导航的基础与深入
- ReactNative基础(六)使用react-navigation实现页面导航布局效果(TabNavigator)
- android 安装器
- dmesg命令
- 大学女生的一天生活调查哇-经典!
- Dijkstra算法求最短路径问题完整C代码
- 2014炼数成金Hadoop应用开发实战案例培训视频教程
- iOS工作记录六 :导航栏(基础实用)
- c#抽象类和接口的区别
- Interger类中进制转换方法的实现原理-通过查表法完成整数的进制转换
- 但是,这有什么用呢?
- HBase vs Cassandra:我们迁移系统的原因
- javascript的对象和数组
- A + B Again (16进制的直接运算)
- [JAVA][ZOJ 1002][Fire Net]
- Xamarin 手动安装步骤+破解(最新版Xamarin V3)