我正在製作一個通用應用程序,我想知道是否可以將初始方向設置爲適用於iPad的橫向和適用於iPhone的縱向?目前,我在info.plist
文件中設置了initial interface orientation
,但它似乎沒有針對iPad和iPhone的不同選項。如果它不能通過info.plist
文件完成,那麼如何以編程方式做到這一點?iPad和iPhone的不同推出方向?
回答
看起來與supported orientation
S中initial interface orientation
屬性衝突。不過,我找到了解決方案here。
編程,你可以做以下使用的代碼 -
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
return YES;
}
}
else {
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
return YES;
}
}
return NO;
}
我在這裏找到了解決方案:http://stackoverflow.com/questions/402/iphone-app-in-landscape-mode – tipycalFlow 2012-04-13 12:07:50
這不是解決方案我一直在尋找,我的朋友......問題在於啓動方向(當iOS尚未開始使用方向通知時,所以'shouldAutorotateToInterfaceOrientation'不會被**調用)。如果你在你的appdelegate中'NSLog'設備的方向,你會得到'orientation unknown'的輸出! – tipycalFlow 2012-04-19 05:15:31
UIDevice* thisDevice = [UIDevice currentDevice];
if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
[[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight];
}
else
{
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
'setOrientation'可以讓我的應用程序被拒絕。不管怎麼說,還是要謝謝你 – tipycalFlow 2012-04-13 12:05:45
- 1. iPad的推出方向
- 2. 通向iPhone和iPad的不同途徑?
- 3. iphone和ipad之間的modalviewcontroller的不同方向行爲
- 4. iPad的推出方向上表面
- 5. iPhone/iPad的橫向方向和UIAlertView
- 6. 針對iPhone和iPad的不同屏幕方向
- 7. 如何不同的方向設置爲iPhone和iPad
- 8. iPad和iPhone的方向問題
- 9. iPad和iPhone的方向問題
- 10. iphone/ipad方向處理
- 11. iPhone和iPad之間的不同行爲
- 12. UITableViewCell在iPhone和iPad上的工作方式不同
- 13. 創建iPad和iPhone運行不同@properties
- 14. 在iPhone/iPad中更改UIImage的方向
- 15. iPhone和iPad VGA輸出
- 16. iPhone/iPad的UIScrollView子視方向和setAutoresizeMask問題
- 17. Xcode:在部署信息下指定iPhone和iPad的方向?
- 18. iPad方向和xib文件
- 19. Yahoo yui和iPad方向
- 20. 不同的故事板爲iPad和iPhone不工作的權利
- 21. iPad的4.2碰撞推出
- 22. iPad和iPad 2渲染CSS的方式不同嗎?
- 23. iPhone/iPad上的不同縮放比例
- 24. iPad推出方向,當應用程序代表出現問題時
- 25. 在iOS(iPad/iPhone)上強制鍵盤和子視圖方向
- 26. 如何在iPhone和ipad for ios6中實現方向?
- 27. WPF和IPAD \ IPHONE
- 28. JCrop和iPad/iPhone
- 29. iPhone/iPad在不同視圖中的不同視圖方向以及蘋果批准過程
- 30. 鍵盤隱藏在ipad中的不同方向的textfield
http://stackoverflow.com/a/17628668/468724 – 2013-07-13 09:07:55