我有这个代码在推特上发送图像。当我尝试这个应用程序时,拾取器工作得很好,但它不能捕获图像。怎么了?
- (IBAction)sendImageTweet:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsEditing = NO;
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSData *imageData = UIImagePNGRepresentation(image);
[self dismissModalViewControllerAnimated:YES];
[tweetViewController addImage:(UIImage *)imageData];
[self presentModalViewController:tweetViewController animated:YES];
}
发布于 2012-01-26 02:15:05
您应该使用常量,而不是NSString和键。
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
https://stackoverflow.com/questions/9007839
复制相似问题