iOS页面跳转及数据传递(三种)
iOS页面跳转:
第一种
[self.navigationControllerpushViewController:subTableViewControlleranimated:YES];
//描述:通过NSNavigationBar进行跳转
[self.navigationControllerpopViewControllerAnimated:YES];
//描述:在子视图返回到上级视图
第二种
UIViewController*control=[[UIViewControlleralloc]init];[selfpresentModalViewController:controlanimated:YES];[controlrelease];
//描述:通过事件进行跳转
[selfdismissModalViewControllerAnimated:YES];
//描述:通过事件进行返回。
第三种
[self.view.windowaddSubview:otherview]; [self.viewremoveFromSuperview]
数据传递:
1)采用代理模式子viewcontroller设计代理协议,定义协议接口,父viewcontroller实现协议接口,实现子viewcontroller退出时将相关数据更新到父视图。
2)采用ios的消息机制父viewcontroller注册消息,子viewcontroller发送消息,触发父viewcontroller的消息处理。
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(setData:)name:kNotificationMessageobject:nil];
//注册监听,其中setData用来处理消息
[[NSNotificationCenterdefaultCenter]postNotificationName:kNotificationMessageobject:selfuserInfo:infoDict];
//发送消息
3)采用database做为数据中间的存储媒介,子viewcontroller将状态数据存入DB,父viewcontroller从DB获取数据更新view.
4)采用ios的NSDefault存储
5)通过AppDelegate中定义全局变量实现中间数据的存储。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持毛票票!
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短