一、XIB文件
項(xiàng)目:XIB_Review0311
1.1
ViewController1 *VC1 = [[ViewController1 alloc]initWithNibName:@"ViewController1" bundle:nil];
注:Nib就是XIB
1.2創(chuàng)建ViewController2時(shí)偏序,忘記勾選XIB的情況
1.2.1 新建文件
1.2.2 設(shè)置名字與ViewController2一樣
1.2.3 拖拽View
1.2.4 運(yùn)行出錯(cuò):未關(guān)聯(lián),未設(shè)置出口
1.2.5 關(guān)聯(lián)文件
生命周期
- (void)viewDidLoad{
[super viewDidLoad];
NSLog(@"視圖已經(jīng)加載完成胖替。");
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"視圖將要顯示");
}
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"視圖已經(jīng)顯示");
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"視圖將要消失");
}
- (void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"視圖已經(jīng)消失");
}
頁面翻轉(zhuǎn)
//跳轉(zhuǎn)方式1:
//通過切換根視圖控制器研儒,來切換任意兩個(gè)ViewController之間的跳轉(zhuǎn)
- (IBAction)flipView:(id)sender
{
ViewController2 *vc2 = [[ViewController2 alloc]init];
UIWindow *window = [UIApplication sharedApplication].delegate.window;
window.rootViewController = vc2;
//vc1→vc2翻頁動(dòng)畫
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3];
//**************對(duì)window做動(dòng)畫************
//當(dāng)vc1→vc2時(shí),vc1.view從window上移除是瞬時(shí)性動(dòng)作独令,所以對(duì)vc1.view做動(dòng)畫是沒有效果的端朵。
//在界面跳轉(zhuǎn)的整個(gè)過程中,window始終存在燃箭,且不會(huì)變動(dòng)冲呢,所以,可以對(duì)window做一個(gè)動(dòng)畫效果
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES];
[UIView commitAnimations];
}
項(xiàng)目:FlipView0311
頁面翻轉(zhuǎn)2:
模態(tài)彈出
ModalPop_0311
ViewController1.m
//兩個(gè)ViewController之間實(shí)現(xiàn)界面跳轉(zhuǎn)的第二種方式:
//模態(tài)彈出:彈出ViewController2
- (IBAction)changeView:(id)sender
{
//1.創(chuàng)建vc2
ViewController2 *vc2 = [[ViewController2 alloc]init];
//2.實(shí)現(xiàn)模態(tài)彈出(無需移除vc1招狸,即可彈出vc2)
[self presentViewController:vc2 animated:YES completion:nil];
}
ViewController2.m
//讓vc2的View消失
- (IBAction)dismiss:(UIButton *)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
代理協(xié)議的使用步驟
1.設(shè)置代理 delegate:self
2.粘貼協(xié)議方法(從UIAlertView.h文件中)
3.實(shí)現(xiàn)協(xié)議方法
自學(xué)UIActionSheet控件
新推出的UIAlertController