如何使UIViewController重新加载视图? [英] How to make UIViewController re-load the view?

查看:81
本文介绍了如何使UIViewController重新加载视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的视图控制器设置为从Nib文件加载视图.在viewDidAppear的某个点上,我可能会更改self.view,并且视图可能会消失,下一次viewDidAppear,我可能决定从笔尖加载原始视图,我该怎么做?

My view controller is set to load the view from Nib file. At some point in viewDidAppear I may change the self.view and the view may disappear, next time viewDidAppear I may decide to load original view from the nib, how would I do that?

推荐答案

一种方法是简单地在viewDidAppear中重新初始化控制器属性对象:

One way to do it is to simply re-initialize your controller property object in the viewDidAppear:

[self setMySubViewController:[[[MySubViewController alloc] initWithNibName...] autorelease]];

您的mySubViewController属性将释放视图控制器的上一个副本,并保留新的副本.

Your mySubViewController property will release the previous copy of the view controller and retain the new one.

希望这会有所帮助.

这篇关于如何使UIViewController重新加载视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆