6
我有一个helloController这是一个UIViewController,如果我旋转设备,我想它改变它加载一个新的笔尖“helloHorizontal.xib”,我该怎么办?谢谢。如何在旋转设备时更换新的笔尖?
我有一个helloController这是一个UIViewController,如果我旋转设备,我想它改变它加载一个新的笔尖“helloHorizontal.xib”,我该怎么办?谢谢。如何在旋转设备时更换新的笔尖?
你可能在你这样的事情,(我没有方便的Xcode所以这个代码可能不完全准确)
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)){
WhatYourNewViewClassISCAlled* newView = [[WhatYourNewViewClassISCAlled alloc] initWithNibName:@"NIBNAME" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:newView animated:YES];
}
这是正确的做法,我相信。我在我的应用程序使用它,它完美的作品
(NB stackoverflow.com这里需要这句话 - 有代码格式错误)
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
{
[[NSBundle mainBundle] loadNibNamed:[NSString stringWithFormat:@"%@-landscape", NSStringFromClass([self class])] owner:self options:nil];
[self viewDidLoad];
}
else
{
[[NSBundle mainBundle] loadNibNamed:[NSString stringWithFormat:@"%@", NSStringFromClass([self class])] owner:self options:nil];
[self viewDidLoad];
}
}
但随后纵向方向看法仍然会在堆栈上,不是吗?所以后退按钮会指向错误的东西。 – 2010-08-19 18:09:12
好点,你可以在视图旋转时隐藏导航栏,或者已经创建了视图并将其淡入,并在旋转发生时淡入其他视图。 – octermircty 2010-08-19 22:21:35