Iphone UIImagePickerController关闭时,仅在iOS 6.0中将视图向上推至20像素
编辑:我正在使用Iphone UIImagePickerController关闭时,仅在iOS 6.0中将视图向上推至20像素,iphone,ios,objective-c,uiimagepickercontroller,Iphone,Ios,Objective C,Uiimagepickercontroller,编辑:我正在使用UIStoryBoard 我已经这样介绍了: UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //| UIImagePickerControllerSourceType
UIStoryBoard
我已经这样介绍了:
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:^{
}];
}
}
[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:^{
}];
}
现在当dissmissed
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = info[UIImagePickerControllerEditedImage];
NSLog(@"Image : %@",image);
[self dismissViewControllerAnimated:YES completion:^{
}];
}
现在,视图
变成这样,如图所示:
编辑:未显示时,视图将被推高到20px
编辑:这仅适用于iOS 6.0版本如果视图的蓝色部分是自定义的
UIView
,则应检查该视图的自动调整大小掩码。你会发现问题。我也有类似的问题,在我的例子中,20像素是状态栏的高度。
因此,在显示imagePicker之前,请尝试将状态栏可见性设置为“否”,在显示完成时设置为“是”(在委托方法中)
大概是这样的:
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:^{
}];
}
}
[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:^{
}];
}
原因是我设置了
视图控制器的帧
,它处于保护模式
,因为它的上一个视图
处于横向模式
self.view.bounds = CGRectMake(0,0,...,...);
每当imagepicker
dissmiss
被调用时,它就会移动到原始位置
,如所述
现在在结构中更改了方向的而没有在外部设置self.view框架
解决了我的问题
我在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];
});
}
在这个屏幕上有tabbar吗?或者您是否在任何地方设置了“图幅”?因为我在我的应用程序中也运行了相同的代码,所以工作正常。是的,我正在设置[self.navigationController.view setBounds:CGRectMake(0,0320480)];在viewDidLoad方法中,蓝色部分是UIView还是导航栏?是的,是UIImageView!!!!!!!我只在iOS 6中遇到了这些问题,而iOS 7.0还没有出现