2013-03-20 61 views
1

從UIImagePickerController中挑選圖像之後我想發送它,但出現錯誤!iOS6問題在UITabBarController中使用從UIImagePickerController拍攝的圖像鳴叫

Warning: Attempt to present <SLTwitterComposeViewController: 0x210d84b0> on <UITabBarController: 0x1fd67650> while a presentation is in progress! 

P.S 這是應用程序的TabBar(4個tabbars)

所有代碼:

-(void)useCamera:(id)sender 
{ 
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ 
     UIImagePickerController *imagePicker =[[UIImagePickerController alloc] init]; 
     imagePicker.delegate = self; 
     imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
     imagePicker.mediaTypes = @[(NSString *) kUTTypeImage]; 
     imagePicker.allowsEditing = NO; 
     [self presentViewController:imagePicker animated:YES completion:nil]; 
     _newMedia = YES; 
    } 
} 

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ 
    NSString *mediaType = info[UIImagePickerControllerMediaType]; 
    [self dismissViewControllerAnimated:YES completion:nil]; 

    if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { 
     [self buttonTweet:info[UIImagePickerControllerOriginalImage]]; 
    } 
} 

- (IBAction)buttonTweet:(id)sender { 

    SLComposeViewController *composeController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; 

    [composeController setInitialText:[NSString stringWithFormat:@"#this is tweet text"]]; 
    [composeController addImage:sender]; 
    [composeController addURL: [NSURL URLWithString:@"http://www.abc.com"]]; 
    [self presentViewController:composeController animated:YES completion:nil]; 
} 

回答

3

您呈現一個新的視圖控制器,而舊的仍然消失。您可以在完成其他動畫時呈現新圖像,如下所示:

[self dismissViewControllerAnimated:YES completion:^{ 
    if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { 
     [self buttonTweet:info[UIImagePickerControllerOriginalImage]]; 
    } 
}]; 
+0

That worked - great! – ksprs8 2013-03-20 19:56:07

相關問題