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