2012-10-09 27 views
7

Merhaba Bir iOS uygulamasında iki UIButton'um var. Birincisi twitter göndermek için ikinci Facebook'a göndermek için. Facebook düğmesi mükemmel çalışıyor ancak tweet bana bazı problemler kaplıyor, tweet sayfası nüfuslu metin ile açılacak, ancak iptal etmek için iptal düğmesinin iki dokunuşunu alıyor. Ben tweet göndermek gönderirseniz gönderilecek ve sayfa reddedilir ama benim app donuyor ve yanıt vermiyor. Ben koduUygulama tweet gönderdikten sonra donuyor

- (IBAction)postTweet:(id)sender { 

// if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]){ 

    myTweet = [[SLComposeViewController alloc]init]; 

    myTweet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; 

    NSString *tweetString = [[NSString alloc]initWithFormat:@"%@\n%@\nvia @ValuatorApp", pdOne.text, pdTwo.text]; 

    [myTweet setInitialText:tweetString]; 

    [myTweet addURL:[NSURL URLWithString:@"http://sjb007.me/TheValuator"]]; 

    [self presentViewController:myTweet animated:YES completion:nil]; 
// } 
[myTweet setCompletionHandler:^(SLComposeViewControllerResult result) { 

    NSString *output = [[NSString alloc]init]; 

    switch (result) { 
     case SLComposeViewControllerResultCancelled: 
      output = @"Twitter Post Cancelled"; 
      break; 
     case SLComposeViewControllerResultDone: 
      output = @"Twitter post Succesful"; 
      break; 
     default: 
      break; 
    } 
    NSLog(@"%@",output); 

}]; 
} 

- (IBAction)postFacebook:(id)sender { 

// if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){ 

    myTweet = [[SLComposeViewController alloc]init]; 

    myTweet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 

if (pd3 != 0) { 
    NSString *facebookString = [[NSString alloc]initWithFormat:@"%@\n%@\n%@", pdOne.text,pdTwo.text, pdThree.text]; 
    [myTweet setInitialText:facebookString]; 

} 
else if (pd3 == 0){ 
    NSString *facebookString = [[NSString alloc]initWithFormat:@"%@\n%@\n", pdOne.text,pdTwo.text]; 
    [myTweet setInitialText:facebookString]; 

} 

// [myTweet addImage:[UIImage imageNamed:@"Photo Jun 02, 22 46 37.jpg"]]; 

[myTweet addURL:[NSURL URLWithString:@"http://sjb007.me/TheValuator"]]; 

[self presentViewController:myTweet animated:YES completion:nil]; 
// } 
[myTweet setCompletionHandler:^(SLComposeViewControllerResult result) { 

    NSString *output = [[NSString alloc]init]; 

    switch (result) { 
     case SLComposeViewControllerResultCancelled: 
      output = @"Facebook Post Cancelled"; 
      break; 
     case SLComposeViewControllerResultDone: 
      output = @"Facebook post Succesful"; 
      break; 
     default: 
      break; 
    } 
    NSLog(@"%@",output); 

}]; 
} 
+1

tam olması halinde aynı sorun, bir düzeltme buldunuz mu? –

cevap

18

Sen ViewController "myTweet"

[self presentViewController:myTweet animated:YES completion:nil]; 

sunuyoruz her iki biti dahil ettik ama hiç orada görevden edilir ... tablosunun completionHandler

[self dismissViewControllerAnimated:YES completion:nil]; 
+2

switch deyimi benim için bu sorunu giderdikten sonra dismiss kodu koyarak, ancak Facebook için gerekli olmayan garip ... –

+4

http://stackoverflow.com/questions/12617490/twitter-post-ios6 bakın -cancel-button-issue? rq = 1 – sjbuchanan007

+0

Bu hem ResultCancelled hem de ResultDone için Twitter'da gereklidir, ancak Facebook'ta değil – RanLearns

İlgili konular