[英]Two nib file and one view controller
In my project i have created two UIView
one for landscape mode and the other for potrait mode. 在我的项目中,我创建了两个UIView
一个用于风景模式,另一个用于potrait模式。 I am using the same same UIViewController
to control both these views. 我正在使用相同的UIViewController
来控制这两个视图。 These two views have the same content, only thing is that when i switch from one UIView
to another the value of the UIControls
is not retained. 这两个视图具有相同的内容,唯一的问题是,当我从一个UIView
切换到另一个UIView
,不会保留UIControls
的值。 I have loaded the UIView enter code here
using the following code 我已经使用以下代码enter code here
加载了UIView enter code here
代码
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"UIViewName"
owner:self
options:nil];
UIView *lview = (UIView *)[nibArray objectAtIndex:0];
lview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Background.jpg"]];
self.view = lview;
Can anybody pliz help me retaining the values during orientation change? 有人可以帮助我在更改方向时保留这些值吗?
You can stock all the values on a NSMutableDictionary in your controller and then put the inputs of the user on the reloaded views when the user changes the orientation. 您可以将所有值存储在控制器中的NSMutableDictionary上,然后在用户更改方向时将用户的输入放在重新加载的视图上。
Look here at theh documentation to see how NSMutableDictionary works: 在此处查看这些文档,以了解NSMutableDictionary的工作方式:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.