1.視圖控制器 ? UIViewController
1.設(shè)置根視圖控制器
RootViewController *rootVC = [[RootViewController alloc] init];
self.window.rootViewController = rootVC;
[rootVC release];
2.導(dǎo)航視圖控制器 ? UINavigationController
標(biāo)題? ? ? ? ? ? ? ? title / navigationItem.title? ? ? ? ? ? ? ? ? ? ? @"abc"
背景顏色 ? ? ?? navigationController.navigationBar.barTintColor ? UIColor cyanColor
設(shè)置不透明 ? ? navigationController.navigationBar.translucent? ??NO
隱藏方式(所有類(lèi)格式要統(tǒng)一) ? ? ? ?1.navigationBarHidden ? ? ? ? ? ? ? ? ? ?YES?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?2.navigationBar.hidden ? ? ? ? ? ? ? ? ? ?YES
樣式 ? ? ? ? ? ?self.navigationController.navigationBar.barStyle ? ? ? ? ? ? ? ? ?UIBarStyleBlack
修改導(dǎo)航欄上內(nèi)容的顏色 ? self.navigationController.navigationBar.tintColor ? ? ? ? UIColor whiteColor
左右按鈕(含點(diǎn)擊事件) ? ? self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(left:)] autorelease];
1.創(chuàng)建導(dǎo)航視圖控制器
MainViewController?*mainVC = [[MainViewController?alloc]init];
UINavigationController?*naVC = [[UINavigationController?alloc]initWithRootViewController:mainVC];
self.window.rootViewController?= naVC;
[mainVC?release];
[naVC?release];
2.觸發(fā)事件進(jìn)入下一頁(yè)
[self.navigationController?pushViewController:secVC?animated:YES];
3.協(xié)議傳值
從后向前傳值
協(xié)議傳值__SecondViewController.h
1.聲明一份協(xié)議
@protocol SecondViewControllerDelegate//協(xié)議方法
-(void)changeValue:(NSString?*)value;
@end
@interface SecondViewController : UIViewController
2.設(shè)置代理人的屬性
@property(nonatomic,assign)iddelegate;
@end
協(xié)議傳值__SecondViewController.m
3.設(shè)置代理人執(zhí)行的協(xié)議方法--寫(xiě)在需要執(zhí)行事件方法里
-(void)click:(UIButton?*)button{
[self.delegate?changeValue:self.textField.text];
}
協(xié)議傳值__MainViewController.m
4.簽訂協(xié)議
@interface MainViewController ()<SecondViewControllerDelegate>
5.設(shè)置代理人對(duì)象
secVC.delegate?=?self;
6.實(shí)現(xiàn)協(xié)議方法
-(void)changeValue:(NSString?*)str{
}
4.屬性傳值
從前向后傳值
屬性傳值__SecondViewController.h
1.在第二個(gè)頁(yè)面寫(xiě)一條屬性
@property(nonatomic,assign)NSInteger?number;
針對(duì)字符串寫(xiě)一條屬性
@property(nonatomic,copy)NSString?*str;
@property(nonatomic,retain)NSArray?*arr;
屬性傳值__MainViewController.h
2.屬性傳值的第二步
-(void)click:(UIButton?*)button{
SecondViewController?*secVC = [[SecondViewController?alloc]?init];
secVC.number?=?100;
secVC.str?=?self.myTextField.text;
secVC.arr?=?@[@"a",@"b"];
[secVC?release];
}
屬性傳值__SecondViewController.m
3.把屬性里的內(nèi)容對(duì)label進(jìn)行賦值
self.label.text?=?self.str;