添加图片到Tweet Sheet - iOS

时间:2013-08-03 14:03:42

标签: ios uiimagepickercontroller tweets

我正在尝试将图像添加到iOS 6应用中的推文表中。我有一个小问题。一旦用户从照片库中选择了图像,我想显示TweetSheet但是我收到以下警告:

  

警告:在演示文稿正在进行时尝试演示!

如何在照片库的解散动画完成后显示推文?

这是我的代码:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
image = [info objectForKey:UIImagePickerControllerOriginalImage];
[self dismissViewControllerAnimated:YES completion:nil];

[self tweet_image];
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)tweet_image {
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {

    SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    [tweetSheet setInitialText:[NSString stringWithFormat: @"@%@ ", USERNAME]];
    [tweetSheet addImage:image];
    [self presentViewController:tweetSheet animated:YES completion:nil];
}

else {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup in iOS settings." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
    [alertView show];
}

}

谢谢,Dan。

2 个答案:

答案 0 :(得分:2)

在-dismissViewControllerAnimated的完成块中调用-tweet_image:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [self dismissViewControllerAnimated:YES completion:^ {
        [self tweet_image];
    }];
}

答案 1 :(得分:0)

我找到了办法。我决定用图像做一个确认屏幕,然后从那里显示推文表。