1
我有這段代碼,設置爲當手機旋轉到橫向時出現clockView,然後當它返回到縱向時使其返回到mainView。但是當它返回到肖像時,肖像視圖處於橫向模式。我該如何解決?這是我的代碼。如何停止mainView旋轉?
-(void)willAnimateRotationToInterfaceOrientation(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
UIInterfaceOrientation toOrientation = self.interfaceOrientation;
if(toOrientation == UIInterfaceOrientationPortrait)
{
self.view = mainView;
}
else if(toOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view = clockView;
}
else if (toOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view = mainView;
}
else if(toOrientation == UIInterfaceOrientationLandscapeRight)
{
self.view = clockView;
}
}