当前位置: 移动技术网 > IT编程>移动开发>IOS > iOS页面跳转及数据传递(三种)

iOS页面跳转及数据传递(三种)

2019年07月24日  | 移动技术网IT编程  | 我要评论

粗口歌词,fs2you下载,230ore-095

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]

数据传递:

1)采用代理模式子viewcontroller设计 代理协议,定义协议接口,父viewcontroller 实现协议接口,实现子viewcontroller 退出时将相关数据更新到父视图。
2)采用ios的消息机制 父viewcontroller注册消息,子viewcontroller 发送消息,触发父viewcontroller的消息处理。

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(setdata:) name:knotificationmessage object:nil];

//注册监听,其中setdata用来处理消息

[[nsnotificationcenter defaultcenter] postnotificationname:knotificationmessage object:self userinfo:infodict];

//发送消息

3)采用database做为数据中间的存储媒介,子viewcontroller将状态数据存入db,父viewcontroller从db获取数据更新view.

4)采用ios的nsdefault 存储

5)通过appdelegate 中定义全局变量实现中间数据的存储。

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持移动技术网!

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网