頁面跳轉(zhuǎn)與返回

———————— ————————————————————————

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];

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容