UIImagePickerController

所以我决定在我的第一个博客中展示他们为我们提供的Apple出色的UIKit UIImagePickerController。 最终,我们将要从事一些项目,而我们自己的一些副项目将需要某种形式的图像,无论是提供信息还是使您的应用程序漂亮。 UIImagePickerController是一个类,它使我们可以访问照相机设备和照片库并将它们显示在我们的故事板上。 下面提供了有关如何使用类似的方式从图库中获取照片的链接:

视频中有一个部分让我感到非常困惑,其中大部分我都不知道为什么要写:

  @synthezise imageView // imageView的属性 
@synthesize imageController; // imageController的属性

显然,@synthesize会为您的属性生成getter和setter方法。 我没有使用这种编码方式,而是创建了一个新的UIImagePickerController实例。

现在好玩开始xP

对于按钮操作,我们需要使用内置视图从库中选择想要的图像。 因此,我们首先基本上制作了UIImagePickerController类的新实例。 我们将代表设置为self,并展示了视图控制器(这是我们的照片库)。

  -(IBAction)buttonToGetImage:(id)发送者 
{
UIImagePickerController * imageController = [[UIImagePickerController alloc] init];
  imageController.delegate =自我; 
  [自己的presentViewController:imageController动画:是完成:无]; 
  }