Dav*_*bbo -1 iphone twitter xcode uiimagepickercontroller ios
我是iOS开发的新手,所以我很困惑.我有一个ViewController,在这个ViewController中有很多UIButtons.如何打开选择器并将图像添加到推文使用addImage?PS:我正在使用Storyboard.
谢谢,抱歉我的英文...... :)
按下按钮时,您需要执行以下操作:
  if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];        
    imagePicker.sourceType =  UIImagePickerControllerSourceTypeSavedPhotosAlbum;  
    imagePicker.delegate = self;
    [self presentModalViewController:imagePicker animated:YES];
  }
你需要实现委托方法.主要是:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
    NSData *imageData = UIImagePNGRepresentation(image);
    // do twitter stuff here....
    [self dismissModalViewControllerAnimated:YES];
}
有关详细信息,请参阅文档:http: //developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/CameraAndPhotoLib_TopicsForIOS/Articles/PickinganItemfromthePhotoLibrary.html#//apple_ref/doc/uid/TP40010408-SW1
| 归档时间: | 
 | 
| 查看次数: | 4051 次 | 
| 最近记录: |