———————— ————————————————————————
storyboard中的每個View Controller,想要實現(xiàn)一些操作,都必須添加關(guān)聯(lián)的類
里面自帶的那個View Controller已近關(guān)聯(lián)了自帶的ViewController
————————————————————————————————
一.storyBoard實現(xiàn)(點擊頁面一按鈕,跳轉(zhuǎn)頁面二. 點擊頁面二按鈕,返回頁面一(
1.創(chuàng)建一個Button (跳轉(zhuǎn))創(chuàng)建— 將Button與下一頁關(guān)聯(lián)Modal
2.在StoryBoard中拖入View Controller,添加返回按鈕
3.需要實現(xiàn)返回按鈕的返回操作,必須關(guān)聯(lián)外面的一個繼與UIViewContrller的類,在類中實現(xiàn)Button的點擊方法關(guān)聯(lián)
————————————————————————————————————————————————
二.使用代碼的方法實現(xiàn)
1.懶加載創(chuàng)建UIButton— 添加點擊事件
2.創(chuàng)建下一頁的ViewController
3.點擊事件
- (void)gotoNextPage:sender{
//根據(jù)名字取到storyboard的引用
? ?UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//根據(jù)storyboard取到ViewController
? ?UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"PurpleViewController"];
? ?//動畫的設置
? ?vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
//根據(jù)ViewController推出視圖
? ?[self presentViewController:vc animated:YES completion:nil];
}