gpt4 book ai didi

ios - 在 iPhone 的 iOS 7 中打开相机时横向模式下的方向问题

转载 作者:行者123 更新时间:2023-12-01 18:59:27 27 4
gpt4 key购买 nike

我有一个仅处于横向模式的应用程序。在我的应用程序中,我从我的一个 View 中打开相机。它在我的 iPad 上运行良好,但在 iPhone 上它崩溃了。它在 iOS 6 中运行良好,但该应用程序在 iOS 7 中崩溃并且仅适用于 iPhone。

下面是我的代码。

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{

ipc=[[UIImagePickerController alloc] init ];
ipc.delegate=self;
ipc.sourceType=UIImagePickerControllerSourceTypeCamera;
[self presentViewController:ipc animated:YES completion:nil];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Desc" message:@"Camera capture is not supported in this device" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}

如何解决这个问题?

当我选择从相机捕捉时它崩溃了。它不会从上面的代码中崩溃,但之后它会因以下错误而崩溃。

我收到此错误:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES



我的应用程序崩溃了。

我在这个 View 上的方向代码。
-(BOOL)shouldAutorotate
{
return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight ;
}

最佳答案

我以前也遇到同样的问题。我按照步骤操作。请试试这个,让我知道你是否面临同样的问题。
复选标记 enter image description here

第1步:
checkin appdelegate.m

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAll;
}

第 2 步:在您的 View Controller 中
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight)
return YES;
return NO;
}

第 3 步:您的 View Controller
-(IBAction)TakePhoto:(id)sender{

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
[self.view.window.rootViewController presentViewController:imagePicker animated:YES completion:nil];//add to view as per requirement
}
else
{
UIAlertView *noCam = [[UIAlertView alloc] initWithTitle:@"Notification" message:@"There is No Camera Fecility" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[noCam show];
}
}

关于ios - 在 iPhone 的 iOS 7 中打开相机时横向模式下的方向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23774068/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com