任何人都可以確認[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
會讓您的應用被Apple拒絕。在iPhone專用API上設置界面方向
有沒有好的替代品可用?
任何人都可以確認[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
會讓您的應用被Apple拒絕。在iPhone專用API上設置界面方向
有沒有好的替代品可用?
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientation]是一個私有API,你可以發現簽名是隻讀的(見here)。
如果你想設置的設備方向爲縱向或其他方式,你應該覆蓋shouldAutorotateToInterfaceOrientation:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIDeviceOrientationPortrait);
}
您可以在您的應用程序的plist
Yes you'll get rejected添加UIInterfaceOrientation。
您可以更改框架並將變換應用到關鍵窗口,並更改狀態欄方向(這是公開的)以模擬更改方向。
你可以試試這段代碼。它完美對我的應用程序
UIApplication* application = [UIApplication sharedApplication];
if (application.statusBarOrientation != UIInterfaceOrientationPortrait)
{
AppDelegate* app = [[UIApplication sharedApplication] delegate];
UIViewController *c = [[UIViewController alloc]init];
[app.viewController presentModalViewController:c animated:NO];
[app.viewController dismissModalViewControllerAnimated:NO];
[c release];
}
其中app.viewController是應用程序的RootViewController的
的UIDevice是不是私人的API。 – thierryb 2010-03-05 13:23:22
對不起,這是一個錯誤,我只是告訴setOrientation是私人的。 – 2010-03-05 13:36:04