0

我正在尝试将图像添加到我的 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];
}

}

谢谢,丹。

4

2 回答 2

2

Place your call to -tweet_image in the completion block of -dismissViewControllerAnimated:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [self dismissViewControllerAnimated:YES completion:^ {
        [self tweet_image];
    }];
}
于 2013-08-03T14:45:02.020 回答
0

I figured out a way. I decided to make a confirmation screen with the image and then display the tweet sheet from there.

于 2013-08-03T14:43:29.997 回答