iOS頁面跳轉:
第一種
[self.navigationController pushViewController:subTableViewController animated:YES];
//描述:通過 NSNavigationBar 進行跳轉
[self.navigationController popViewControllerAnimated:YES];
//描述:在子視圖返回到上級視圖
第二種
UIViewController *control = [[UIViewController alloc] init]; [self presentModalViewController:control animated:YES]; [control release];
//描述:通過事件進行跳轉
[self dismissModalViewControllerAnimated:YES];
//描述:通過事件進行返回。
第三種
[self.view.window addSubview:otherview];[self.view removeFromSuperview]
數(shù)據(jù)傳遞:
1)采用代理模式子viewcontroller設計 代理協(xié)議,定義協(xié)議接口,父viewcontroller 實現(xiàn)協(xié)議接口,實現(xiàn)子viewcontroller 退出時將相關數(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ù)的存儲。
以上就是本文的全部內容,希望本文的內容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持VEVB武林網!
新聞熱點
疑難解答