即使您嘗試在橫向上啓動您的應用程序,您的手機將以縱向啓動它,然後根據手機在哪個位置進入橫向。
我不知道你用什麼代碼來完成這個。以下是從Apple代碼片段中獲取的一個代碼片段。看看這是否有幫助。
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation duration:(NSTimeInterval)duration {
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
self.view = self.portrait;
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view = self.landscape;
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
self.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
}
else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view = self.portrait;
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
self.view = self.landscape;
self.view.transform = CGAffineTransformIdentity;
self.view.transform =
CGAffineTransformMakeRotation(degreesToRadian(90));
self.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
}
}
來源
2010-04-01 11:04:30
Leo
沒有具體的想法什麼是錯的,但我想我會問在UI中發生了什麼奇怪的事情時我總是問自己:「你在UIKit之外的主線程中調用了什麼?」 – lawrence 2010-02-03 08:35:01
感謝您的評論。不,我確定我沒有這樣做!這一切都非常令人費解。 – 2010-03-30 08:18:47
此行爲僅在您的應用中發生,還是您在其他應用中看到它行爲異常? – Jasarien 2010-03-30 14:08:08