iOS頁面跳轉(zhuǎn)及數(shù)據(jù)傳遞(三種)
iOS頁面跳轉(zhuǎn):
第一種
[self.navigationController pushViewController:subTableViewController animated:YES];
//描述:通過 NSNavigationBar 進行跳轉(zhuǎn)
[self.navigationController popViewControllerAnimated:YES];
//描述:在子視圖返回到上級視圖
第二種
UIViewController *control = [[UIViewController alloc] init]; [self presentModalViewController:control animated:YES]; [control release];
//描述:通過事件進行跳轉(zhuǎn)
[self dismissModalViewControllerAnimated:YES];
//描述:通過事件進行返回。
第三種
[self.view.window addSubview:otherview]; [self.view removeFromSuperview]
數(shù)據(jù)傳遞:
1)采用代理模式子viewcontroller設計 代理協(xié)議,定義協(xié)議接口,父viewcontroller 實現(xiàn)協(xié)議接口,實現(xiàn)子viewcontroller 退出時將相關(guān)數(shù)據(jù)更新到父視圖。
2)采用ios的消息機制 父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ù)中間的存儲媒介,子viewcontroller將狀態(tài)數(shù)據(jù)存入DB,父viewcontroller從DB獲取數(shù)據(jù)更新view.
4)采用ios的NSDefault 存儲
5)通過AppDelegate 中定義全局變量實現(xiàn)中間數(shù)據(jù)的存儲。
以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持腳本之家!
相關(guān)文章
詳解iOS的Core Animation框架中的CATransform3D圖形變換
CATransform3D一般用于操作view的layer的,是Core Animation的結(jié)構(gòu)體,可以用來做比較復雜的3D操作,這里我們就帶大家來詳解iOS的Core Animation框架中的CATransform3D圖形變換2016-07-07iOS逆向工程使用dumpdecrypted工具給App脫殼
這篇文章主要介紹了iOS逆向工程使用dumpdecrypted工具給App脫殼的相關(guān)資料,本文圖文并茂給大家介紹的非常詳細,具有參考借鑒價值,需要的朋友可以參考下2016-09-09iOS schem與Universal Link 調(diào)試時踩坑解決記錄
這篇文章主要為大家介紹了iOS schem與Universal Link 調(diào)試時踩坑解決記錄,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-01-01Objective-C中字符串NSString的常用操作方法總結(jié)
這篇文章主要介紹了Objective-C中字符串NSString的常用操作方法總結(jié),Objective-C中NSString和NSMutableString這兩個類下包含了操作字符串的大多數(shù)方法,需要的朋友可以參考下2016-04-04