我正在使用基本上在橫向模式下運行的遊戲。 它可以選擇更改Profile Pic。 配置文件圖片選項打開用於在配置文件圖片圖片視圖上顯示的圖片選擇器。 我的問題是應用程序在ios中更改方向時崩潰7
當圖像選擇器打開時,應用程序自動將方向改爲肖像。
爲了解決這個問題,我試過,當他點擊上傳圖片按鈕,然後選擇圖片後,我強行改變設備取向上一個捕獲用戶的方向。 一切工作正常在iPhone 5和更高版本。但是,當用戶從選擇器視圖中選擇圖像時,iPhone 4(在ios7上運行)崩潰。我收到以下錯誤 -
preferredInterfaceOrientationForPresentation必須返回受支持的接口方向!
我使用此代碼來檢查用戶
-(void)checkCurrentDeviceOrientation
{
if([UIDevice currentDevice].orientation ==
UIDeviceOrientationLandscapeRight || [UIDevice
currentDevice].orientation == UIDeviceOrientationLandscapeLeft)
{
self.currentOrientation = [UIDevice currentDevice].orientation;
}
else
{
self.currentOrientation = UIDeviceOrientationLandscapeRight;
}
}
的方向和使用此代碼來設置方向。
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8"))
{
if([UIDevice currentDevice].orientation ==
UIDeviceOrientationPortrait ||[UIDevice currentDevice].orientation ==
UIDeviceOrientationPortraitUpsideDown )
{
NSLog(@"Chnaging Device Orientation to stored orientation");
NSNumber *value = [NSNumber numberWithInt:self.currentOrientation];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
}
else
{
//Code For IPHONE 4
}
希望一切正常iOS8上和更高但不是在iPhone 4在iOS 7.0.1
在此先感謝跑!
[preferredInterfaceOrientationForPresentation必須返回支持的接口方向]的可能重複(http://stackoverflow.com/questions/12690963/preferredinterfaceorientationforpresentation-must-return-a-supported-interface-o) – Koen