1
我目前正在研究一個應用程序,當用戶將設備轉到橫向視圖時,我想從一個屏幕轉換到另一個屏幕。我有這個工作,但正在轉換的屏幕旋轉到橫向視圖,就像下一個視圖進入一樣。防止當前視圖旋轉的常見解決方案是爲shouldAutoRotate方法返回NO。不過,我需要啓用此功能才能轉換到下一個屏幕。我也玩弄了willRotateToInterfaceOrientation中的[UIView setAnimationsEnabled:NO],但這隻隱藏了動畫,並且仍然將當前視圖旋轉爲橫向。這裏有所有相關的旋轉方法:iPhone Autorotation - 禁用視圖旋轉動畫但是轉換到另一個屏幕
-(BOOL)shouldAutorotate
{
return YES;
}
//Temporarily disable rotation animation
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[UIView setAnimationsEnabled:NO];
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[UIView setAnimationsEnabled:YES];
if(UIInterfaceOrientationLandscapeLeft)
[self performSegueWithIdentifier:@"landscapeView" sender:self];
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
有什麼建議嗎?提前致謝。