0

编辑:我正在使用UIStoryBoard.

我有presented这样的:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.delegate = self;

imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //| UIImagePickerControllerSourceTypeSavedPhotosAlbum ;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil];

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
    {
        imagePicker.allowsEditing = YES;
        [self.navigationController presentViewController:imagePicker animated:YES completion:^{

        }];  
    }
}

现在,当dissmissed

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   UIImage *image = info[UIImagePickerControllerEditedImage];
    NSLog(@"Image : %@",image);
    [self dismissViewControllerAnimated:YES completion:^{
    }];
}

现在view变成如下所示fiqure

在此处输入图像描述

编辑:视图在被解雇时被推高到 20px。

编辑:这仅在 iOS 6.0 中

4

4 回答 4

1

原因是我正在设置它的框架view controllerprotrait modeprevious viewlandscape mode

self.view.bounds = CGRectMake(0,0,...,...);

每当imagepicker dissmiss得到called它作为. moved_original positionmentioned

现在更改structureorientation 无需在外部设置 self.view 框架 solved我的problem.

于 2013-06-12T05:49:15.807 回答
0

我有类似的问题,在我的情况下,状态栏高度为 20 像素。因此,尝试在显示 imagePicker 之前将状态栏可见性设置为 NO,并在完成时设置为 YES(在委托方法中)。

像这样的东西:

[UIApplication sharedApplication].statusBarHidden = YES;
[self.navigationController presentViewController:imagePicker animated:YES completion:^{
        }];


-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   // ... your code here
   [UIApplication sharedApplication].statusBarHidden = NO;
   [self dismissViewControllerAnimated:YES completion:^{
    }];
}
于 2013-05-23T08:16:39.677 回答
0

如果视图的蓝色部分是自定义的,UIView那么您应该检查该视图的自动调整大小掩码。你会发现问题。

于 2013-05-23T05:29:52.853 回答
0

我在 iOS 8.2 上遇到了类似的问题。使用 UIImagePickerController 选择视频后,帧增加了 20px,视图控制器的顶部区域看起来不错,但底部被切断。解决方案是:

-(void)openPicker {}
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    //configure image picker here
    [self presentViewController:picker animated:YES completion:NULL];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(showStatusBar) userInfo:nil repeats:NO];
    [picker dismissViewControllerAnimated:YES completion:NULL];
}

-(void)showStatusBar {
    dispatch_async(dispatch_get_main_queue(), ^{
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
    });
}
于 2015-06-12T09:46:22.503 回答