2013-08-03 39 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

我想出了一個辦法。我決定在圖片上做一個確認屏幕,然後從那裏顯示推文表格。