iOS頁面跳轉(zhuǎn)及數(shù)據(jù)傳遞(三種)
iOS頁面跳轉(zhuǎn):
第一種
[self.navigationController pushViewController:subTableViewController animated:YES];
//描述:通過 NSNavigationBar 進(jìn)行跳轉(zhuǎn)
[self.navigationController popViewControllerAnimated:YES];
//描述:在子視圖返回到上級視圖
第二種
UIViewController *control = [[UIViewController alloc] init]; [self presentModalViewController:control animated:YES]; [control release];
//描述:通過事件進(jìn)行跳轉(zhuǎn)
[self dismissModalViewControllerAnimated:YES];
//描述:通過事件進(jìn)行返回。
第三種
[self.view.window addSubview:otherview]; [self.view removeFromSuperview]
數(shù)據(jù)傳遞:
1)采用代理模式子viewcontroller設(shè)計(jì) 代理協(xié)議,定義協(xié)議接口,父viewcontroller 實(shí)現(xiàn)協(xié)議接口,實(shí)現(xiàn)子viewcontroller 退出時(shí)將相關(guān)數(shù)據(jù)更新到父視圖。
2)采用ios的消息機(jī)制 父viewcontroller注冊消息,子viewcontroller 發(fā)送消息,觸發(fā)父viewcontroller的消息處理。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setData:) name:kNotificationMessage object:nil];
//注冊監(jiān)聽,其中setData用來處理消息
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationMessage object:self userInfo:infoDict];
//發(fā)送消息
3)采用database做為數(shù)據(jù)中間的存儲(chǔ)媒介,子viewcontroller將狀態(tài)數(shù)據(jù)存入DB,父viewcontroller從DB獲取數(shù)據(jù)更新view.
4)采用ios的NSDefault 存儲(chǔ)
5)通過AppDelegate 中定義全局變量實(shí)現(xiàn)中間數(shù)據(jù)的存儲(chǔ)。
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!
相關(guān)文章
IOS如何在Host App 與 App Extension 之間發(fā)送通知
這篇文章主要介紹了IOS如何在Host App 與 App Extension 之間發(fā)送通知 的相關(guān)資料,需要的朋友可以參考下2016-03-03
IOS等待時(shí)動(dòng)畫效果的實(shí)現(xiàn)
查詢時(shí)間有長有短,為了增強(qiáng)用戶體驗(yàn)度,目前用的比較多的手段之一是查詢等待時(shí)添加一個(gè)動(dòng)態(tài)等待效果,這篇文章主要介紹IOS等待時(shí)動(dòng)畫效果的實(shí)現(xiàn),有需要的朋友可以參考下2015-08-08
iOS開發(fā)教程之UIRefreshControl使用的踩坑指南
UIRefreshControl是iOS6自帶的UITableView下拉刷新控件。下面這篇文章主要給大家介紹了關(guān)于iOS開發(fā)教程之UIRefreshControl使用的踩坑指南,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2018-04-04

