【发布时间】:2014-01-07 12:52:05
【问题描述】:
我在 Twitter SLComposeViewController 上遇到了一个奇怪的问题。我现在在 imagePickerController 方法中有一个错误,上面写着“将 void 发送到不兼容类型 void (^)(void) 的参数”
我还收到一条警告,其中包含 twitter 图像“从 imagepicker 中选择的图像”我如何从图像选择器中实际获取图像?谢谢!!
这是拍照动作:
-(void) photoAction {
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc]
init];
#if TARGET_IPHONE_SIMULATOR
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
#else
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
#endif
imagePickerController.editing = YES;
imagePickerController.delegate = (id)self;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
这是下一个方法:
-(void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[[picker presentingViewController] dismissViewControllerAnimated:YES completion:[self showTweetSheet]];
}
最后是推文方法:
-(void)showTweetSheet
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:
SLServiceTypeTwitter];
tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) {
switch(result) {
case SLComposeViewControllerResultCancelled:
break;
case SLComposeViewControllerResultDone:
break;
}
};
[tweetSheet setInitialText:@"Text"];
if (![tweetSheet addImage:@"image selected from imagepicker"]) {
NSLog(@"Unable to add the image!");
}
if (![tweetSheet addURL:[NSURL URLWithString:@"http://twitter.com/"]]){
NSLog(@"Unable to add the URL!");
}
[self presentViewController:tweetSheet animated:NO completion:^{
NSLog(@"Tweet sheet has been presented.");
}];
}
【问题讨论】:
标签: ios iphone objective-c twitter