2

我的应用程序仅在横向模式下运行。

我读到这个并说 UIImagePickerController 只加载纵向模式。

如何旋转应用程序以选择图像并再次返回横向模式。

我有这段代码,我的应用程序崩溃了。

- (IBAction)LoadImage:(id)sender {


        UIImagePickerController * picker = [[UIImagePickerController alloc] init];
        picker.delegate=self;
        [picker setSourceType:(UIImagePickerControllerSourceTypePhotoLibrary)];
        [self presentViewController:picker animated:YES completion:Nil];

}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    [self dismissViewControllerAnimated:NO completion:nil];
  //.....
}

我试试这个但不工作......

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

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationMaskPortrait);
}
4

2 回答 2

3

在您的代码中

(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    [##self## dismissViewControllerAnimated:NO completion:nil];
  //.....
}

如果你想关闭选择器,self## 应该替换为 ##picker##

于 2013-10-01T17:53:17.803 回答
0

你只需要再次导航到你当前的视图它对我有用

于 2014-08-08T13:06:58.163 回答