如何动态更改UIVIewController的xib [英] How to change dynamically the xib of a UIVIewController

查看:64
本文介绍了如何动态更改UIVIewController的xib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我有一个UIVIewController"controller1".该控制器通过带有"file1.xib"的initWithNibName ...实例化. 我想将我的"controller1"的xib文件动态更改为"file2.xib"

I have an UIVIewController "controller1" for instance. This controller is instanciated with initWithNibName... with "file1.xib". I want to dynamically change the xib file of my "controller1" to "file2.xib"

要继续:

"controller1"<->"file1.xib" 我想动态地拥有: "controller1"<->"file2.xib"

"controller1" <-> "file1.xib" and I want to dynamically have : "controler1" <-> "file2.xib"

我该怎么做?

希望我很清楚.

推荐答案

要在UIViewController中更改视图,只需使用以下代码:

When you want to change views in a UIViewController just just use this code:

NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"file2" owner:self options:nil];
UIView *aView = [nibObjs objectAtIndex:0];
self.view = aView;

这篇关于如何动态更改UIVIewController的xib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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