UIImagePickerController被解散时,只在iOS 6.0中将视图推到20像素
编辑 :我正在使用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
如下图所示:
编辑 :视图获取推到20px时dissassed。
编辑 :这仅在iOS 6.0中
原因是我设置的view controller
previous view
protrait mode
因为它previous view
是在landscape mode
。
self.view.bounds = CGRectMake(0,0,...,...);
每当imagepicker
dissmiss
被called
它moved
到original position
mentioned
。
现在在structure
改变了orientation
而没有设置self.view框架在外面 solved
我的problem
。
如果该视图的蓝色部分是自定义UIView
那么你应该检查该视图的自动resize的掩码。 你会发现这个问题。
我有类似的问题,在我的情况下,20像素是状态栏的高度。 因此,尝试在显示imagePicker之前将状态栏可见性设置为NO,并在完成时(在委托方法中)将YES设置为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:^{ }]; }
我有类似的问题在iOS 8.2。 使用UIImagePickerController拾取video后,帧增加了20px,视图控制器的顶部区域看起来不错,但底部被切断。 解决scheme是:
-(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]; }); }