这个问题已经有了答案:
Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
14个答案
*我的视图是在land scape模式下,我正在保存图像,我希望该图像返回,因为我的代码在下面,并且我得到错误“由于未注意到的异常而终止应用程序”uiapplicationInvalidinterfaceOrientation“,原因:“支持的方向与应用程序没有共同的方向,并且shouldAutoRotate正在返回yes'”对于iphone?
`- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissModalViewControllerAnimated:YES];
[picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:NO];
imageDoodle.image = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
}
-(IBAction)loadfromalbumclicked:(id)sender
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing=NO;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
// self.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:picker animated:YES];
}
-(IBAction)savePrint{
//Save image to iOS Photo Library
UIImageWriteToSavedPhotosAlbum(imageDoodle.image, nil, nil, nil);
//Create message to explain image is saved to Photos app library
UIAlertView *savedAlert = [[UIAlertView alloc] initWithTitle:@"Saved"
message:@"Your picture has been saved to the photo library, view it in the
Photos app." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
//Display message alert
[savedAlert show];
}`
最佳答案
尝试将shouldautrotate设置为no,看看它是否有效。
可以在ios 6.0或更高版本中使用shouldautrotate和supportedinterfaceorientations方法,而不是(不推荐使用)shouldautrotatetointerfaceorition方法。
像这样的东西-
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
- (BOOL) shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
关于iphone - “受支持的方向与应用程序没有共同的方向,并且应该Autorotate返回YES” ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14456879/