Добавить изображение в твит-лист — iOS

Я пытаюсь добавить изображение на лист твитов в своем приложении для 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];
}

}

Спасибо, Дэн.


person Supertecnoboff    schedule 03.08.2013    source источник


Ответы (2)


Поместите вызов -tweet_image в блок завершения -dismissViewControllerAnimated:

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

Я придумал способ. Я решил сделать экран подтверждения с изображением, а затем вывести лист твитов оттуда.

person Supertecnoboff    schedule 03.08.2013