我正在尝试将上传图像功能添加到我的 iphone 应用程序,这样当用户访问他们的主页时,他们可以从手机上传照片,下次他们访问该照片时将显示该照片。
我有的 :
//Button action to add upload function
-(IBAction)upload:(id)sender
{
UIImagePickerController *pics = [[UIImagePickerController alloc] init];
pics.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
pics.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentViewController:pics animated:YES completion:NULL];
[pics release];
}
- (void)imagePickerController:(UIImagePickerController *) Picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// replace image holder with chosen image
_imageView1.image=UIImagePickerControllerSourceTypePhotoLibrary;
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *) Picker
{
[self dismissViewControllerAnimated:YES completion:NULL];
}