2013-05-05 47 views
0

我一直在升級我的應用程序以同時使用FB和Twitter發佈......我已經從原始的twitter功能升級,但現在當FBSheet和Twitter表格出現時我發佈消息後,應用程序失去焦點,我無法再訪問它下面的屏幕。以下是我對這些帖子的陳述聲明......我找不到任何明顯的東西。在iOS 6.1上使用social.h功能時輸入功能失效

int social_status = 0; 
if (twitterEnabled) { 
    social_status=1; 
} 
if (facebookEnabled) { 
    social_status=2; 
} 
if (twitterEnabled && facebookEnabled) { 
    social_status = 3; 
} 

switch (social_status) { 
    case kTwitterOn:{ 

     SLComposeViewController *tweetSheet =[[SLComposeViewController alloc] init]; 
     // Sets viewcontroller to twitter type 
     tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter]; 
     SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){ 
      [tweetSheet dismissViewControllerAnimated:YES completion:nil]; 

      switch(result){ 
       case SLComposeViewControllerResultCancelled: 
       default: 
       { 
        NSLog(@"Cancelled....."); 

       } 
        break; 
       case SLComposeViewControllerResultDone: 
       { 
        NSLog(@"Posted...."); 
       } 
        break; 
      }}; 
     tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter]; 
     [tweetSheet setInitialText:message]; 
     [tweetSheet setCompletionHandler:completionHandler]; 
     [self presentViewController:tweetSheet animated:YES completion:nil]; 
     tweetSheet=nil; 
    } 
     break; 

    case kFacebookOn: { 
     SLComposeViewController *faceBookSheet=[[SLComposeViewController alloc] init]; 
     // Sets viewcontroller to FB type 
     faceBookSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook]; 
     SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){ 
      [faceBookSheet dismissViewControllerAnimated:YES completion:nil]; 

      switch(result){ 
       case SLComposeViewControllerResultCancelled: 
       default: 
       { 
        NSLog(@"Cancelled....."); 

       } 
        break; 
       case SLComposeViewControllerResultDone: 
       { 
        NSLog(@"Posted...."); 
       } 
        break; 
      } 
     }; 
     //Calls the function for set Text 
     [faceBookSheet setInitialText:message]; 
     [faceBookSheet setCompletionHandler:completionHandler]; 
     //Presenting the FB sheet 
     [self presentViewController:faceBookSheet animated: YES completion: nil]; 
     faceBookSheet=nil; 
    } 
     break; 

    case kTwitterAndFacebookOn:{ 

     SLComposeViewController *tweetSheet =[[SLComposeViewController alloc] init]; 
     // Sets viewcontroller to twitter type 
     tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter]; 
     SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){ 
      [tweetSheet dismissViewControllerAnimated:YES completion:nil]; 

      switch(result){ 
       case SLComposeViewControllerResultCancelled: 
       default: 
       { 
        NSLog(@"Cancelled....."); 
       } 
        break; 
       case SLComposeViewControllerResultDone: 
       { 
        NSLog(@"Posted...."); 
       } 
        break; 
      } 
     }; 
     tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter]; 
     [tweetSheet setInitialText:message]; 
     [tweetSheet setCompletionHandler:completionHandler]; 
     [self presentViewController:tweetSheet animated:YES completion:nil]; 
     tweetSheet=nil; 

     SLComposeViewController *faceBookSheet=[[SLComposeViewController alloc] init]; 
     // Sets viewcontroller to FB type 
     faceBookSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook]; 
     SLComposeViewControllerCompletionHandler __block completionHandler2=^(SLComposeViewControllerResult result){ 
      [faceBookSheet dismissViewControllerAnimated:YES completion:nil]; 

      switch(result){ 
       case SLComposeViewControllerResultCancelled: 
       default: 
       { 
        NSLog(@"Cancelled....."); 
       } 
        break; 
       case SLComposeViewControllerResultDone: 
       { 
        NSLog(@"Posted...."); 
       } 
        break; 
      } 
     }; 
     //Calls the function for set Text 
     [faceBookSheet setInitialText:message]; 
     [faceBookSheet setCompletionHandler:completionHandler2]; 
     //Presenting the FB sheet 
     [self presentViewController:faceBookSheet animated: YES completion: nil]; 
     faceBookSheet=nil; 
    } 
     break; 

    default: 
    { 
     // We show this Alert if there is no Twitter Enablement 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Quorum Reached" message:message delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil]; 
     [alert show]; 
    } 
     break; 
} 

有什麼建議嗎?

+0

好吧。我已經能夠清理代碼很多..(甚至切換回到一組簡單的If語句),只有當Twitter和Facebook都處於活動狀態時纔會出現問題。似乎Twitter發佈如此之快,並交叉發佈到我的帳戶到Facebook ...在這一點上,我得到了屏幕鎖定。 – 2013-05-05 20:43:41

回答

0

確定..我發現,我已經重複行 tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter]; 所以這是造成問題的原因...