【发布时间】:2010-08-06 10:11:58
【问题描述】:
我是 iphone 开发新手..
我正在创建一个小型应用程序,其中两个视图控制器类似
- 登录控制器
- 更新控制器
对于应用方向,我为每个控制器创建了两个视图,例如 为了 第一个控制器是“landscapeLoginView”和“portraitLoginView” & 其次是 'landscapeUpdateView' 和 'portraitUpdateView'
我在 MainControllerDelegate 文件中定义了 'isLogin' 变量,
定位代码如下,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
TestAppDelegate *testDelegate = (TestAppDelegate *)[[UIApplication sharedApplication] delegate];
if(testDelegate.isLogin) {
UpdateController *updateController = [[UpdateController alloc] initWithNibName:@"UpdateController" bundle:nil];
[self.view addSubview:updateController.view];
[updateController release];
return YES;
} else
{
if(UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
self.view = self.portrait;
}
else if (UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
self.view = self.landscape;
}
return YES;
}
}
这将在单击“登录”按钮后加载尊重的方向。 'LoginController' 的一切工作正常,如按钮事件和所有。
但是, 当我在“UpdateConroller”上输入并通过单击“更新”按钮从 TextView 更新文本时,它会更新为“PortraitView”而不是“LandscapeView”。
在 Interface Builder 中,我将“PortraitView”设置为“view”。
我怎样才能为“LandscapeView”实现相同的功能?我做得对吗?
【问题讨论】:
标签: iphone