在iOS 6.1上使用social.h功能时输入功能失效

问题描述:

我一直在升级我的应用程序以同时使用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

确定..我发现,我已经重复行 tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter]; 所以这是造成问题的原因...