iOS7故事板图像选择器无法正常工作:( [英] iOS7 Storyboard image picker not working :(

查看:89
本文介绍了iOS7故事板图像选择器无法正常工作:(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在使用故事板的新iOS7 Xcode项目中设置 imagePicker 但在找到以下代码之前似乎无法在线找到任何示例。

Im trying to set up an imagePicker in a new iOS7 Xcode project using storyboards but can't seem to find any examples online until I found the following code.

我已经设置好了,当按下按钮时,它会使用模态推送来导航到具有类的视图UIImagePickerController显然调用了图像选择器代码。

I've set it up so that when a button is pressed it uses a modal push thing to navigate to the view which has the class of "UIImagePickerController" which apparently calls in the image picker code.

然而,当应用程序运行时,点击允许应用程序访问您的照片后,任何获得一些帮助的机会都不会加载任何内容吗?

However when the app is run it won't load anything up after clicking on allow the application to access your photos any chance of some help please?

抓取错误屏幕: https://pbs.twimg.com/media/Bdy7v9JCAAABpvS.jpg:large

界面设置:

@interface ridecount_AddRide_ViewController : UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate>{

代码:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    UIImagePickerController *controller = [segue destinationViewController];
    controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    controller.delegate = self;
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [self dismissViewControllerAnimated:YES completion:nil];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    [self dismissViewControllerAnimated:YES completion:nil];
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [[self.view viewWithTag:100023] removeFromSuperview];
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(320/2-200/2, 10, 100, 100)];
    imageView.tag = 100023;
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    imageView.image = image;
    [self.view addSubview:imageView];
}


推荐答案

初始化控制器 UIImagePickerController * controller = [[segue destinationViewController] init];

Initialize the controller UIImagePickerController *controller = [[segue destinationViewController] init];

这篇关于iOS7故事板图像选择器无法正常工作:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆