2013-08-03 34 views
0

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

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

如何在照片库的退出动画完成后显示照片?

这里是我的代码:

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

}

感谢,丹。

回答

2

将您的来电中-dismissViewControllerAnimated完成块-tweet_image:

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

非常感谢:) – Supertecnoboff

0

我想出了一个办法。我决定在图片上做一个确认屏幕,然后从那里显示推文表格。