ViewController 應用
再第一個XIB頁面創建另一個XIB頁面,並且通過按鈕調用它
- (IBAction)GoSecond:(id)sender {
secondViewController *secVC = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil];
secVC.modalTransitionStyle = UIModalPresentationPageSheet;
[self presentViewController:secVC animated:YES completion:^{
NSLog(@"success ");
}];
}
在第二個XIB頁面創建一個按鈕,按鈕PRESS返回第一個頁面
- (IBAction)Backfirst:(id)sender {
[self dismissViewControllerAnimated:YES completion:^{
NSLog(@"dismiss");
}];
}
創造生命周期函數:
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
NSLog(@"view will appear");
}
-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSLog(@"view did appear");
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
NSLog(@"view will disappear");
}
-(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated];
NSLog(@"view did disappear");
}
頁面切換方法:
secVC.modalTransitionStyle = UIModalPresentationPageSheet;
UIModalPresentationFullScreen = 0,
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
UIModalPresentationPageSheet,
UIModalPresentationFormSheet,
UIModalPresentationCurrentContext,
#endif
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0
UIModalPresentationCustom,
UIModalPresentationNone = -1,