【问题标题】:Add image to Tweet Sheet - iOS将图像添加到推文表 - iOS
【发布时间】:2013-08-03 14:03:42
【问题描述】:

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

警告:在演示过程中尝试继续演示!

如何在照片库的关闭动画完成后显示 Tweet Sheet?

这是我的代码:

-(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];
}

}

谢谢,丹。

【问题讨论】:

    标签: ios uiimagepickercontroller tweets


    【解决方案1】:

    将您对 -tweet_image 的调用放在 -dismissViewControllerAnimated 的完成块中:

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

    【讨论】:

      【解决方案2】:

      我想出了一个办法。我决定用图像制作一个确认屏幕,然后从那里显示推文表。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-07-09
        • 1970-01-01
        • 2014-01-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-06
        相关资源
        最近更新 更多