Сбой ориентации UIPopoverController в iOS 6
Моя текущая программа поддерживает только ориентацию ландшафта.
В iOS 6 он падает на UIPopoverController
.
'UIApplicationInvalidInterfaceOrientation', причина: "Поддерживается ориентации не имеют общей ориентации с применением, и shouldAutorotate возвращает YES '
Я разрешаю всю ориентацию проекта, он работает хорошо. Тем не менее, мне нужно многое изменить для всех просмотров, чтобы поддерживать только пейзаж.
Есть ли другой простой способ исправить, UIOrientation
в UIPopoverController
?
Ответы
Ответ 1
Попробуйте добавить к вашему UIApplicationDelegate
следующее:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}
Вы по-прежнему можете настроить поддерживаемые ориентации интерфейса в вашем файле Info.plist
и возвратить маску в каждом методе контроллера supportedInterfaceOrientations:
.
Ответ 2
Новый подкласс UIImagePickerController и добавьте следующие коды:
@property (nonatomic)NSUInteger supportedInterfaceOrientations;
-(NSUInteger)supportedInterfaceOrientations{
return _supportedInterfaceOrientations;
}
-(BOOL)shouldAutorotate{
return YES;
}
Используйте его следующим образом:
if (imagePickerController==nil) {
imagePickerController = [[WUIImagePickerController alloc]init];//the subclass
imagePickerController.delegate = self;
imagePickerController.supportedInterfaceOrientations = UIInterfaceOrientationMaskLandscapeRight;//any orientation you want to set
if (popoverController==nil) {
popoverController = [[UIPopoverController alloc]initWithContentViewController:imagePickerController];
}
}
Кто знает лучший способ, скажите мне.
Ответ 3
Thy this ссылка. Вы должны настроить приложение для поддержки всех ориентаций в начале. Внесите изменения в делегат приложения.
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return UIInterfaceOrientationMaskAll;
else /* iphone */
return UIInterfaceOrientationMaskAllButUpsideDown;
}
Ответ 4
@interface NonRotatingUIImagePickerController : UIImagePickerController
@end
@implementation NonRotatingUIImagePickerController
- (BOOL)shouldAutorotate
{
return NO;
}
@end
UIImagePickerController *picker = [[NonRotatingUIImagePickerController alloc] init];
Используйте выше код, это сработало для меня.
Ответ 5
Use these delegates for orientation,
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}