UISmagePickerController在被解雇时仅在iOS 6.0中将视图推送到20像素

时间:2013-05-23 04:51:23

标签: iphone ios objective-c uiimagepickercontroller

编辑:我正在使用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

enter image description here

编辑:当被解雇时,视图会被提升至20像素。

编辑:这仅适用于iOS 6.0

4 个答案:

答案 0 :(得分:1)

原因是我view controller protrait mode的{​​strong>设置框架,previous view landscape mode位于self.view.bounds = CGRectMake(0,0,...,...);

imagepicker

每当dissmiss called moved original position mentioned structureorientation时。

现在更改为solved problem 而未在外部设置self.view框架 {{1}}我的{{1}}。

答案 1 :(得分:0)

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

答案 2 :(得分: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:^{
    }];
}

答案 3 :(得分: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];
    });
}