【问题标题】:Losing input capabilities when using social.h functions on iOS 6.1在 iOS 6.1 上使用 social.h 函数时丢失输入功能
【发布时间】:2013-05-05 18:08:35
【问题描述】:

我一直在升级我的应用程序以同时使用 FB 和 Twitter 发帖...我已从原始 twitter 功能升级,但现在当 FBSheet 和 Twitter 表格出现并发布消息时,应用程序失去焦点,我无法再访问其下方的屏幕。这是我对这些帖子的案例陈述......我找不到任何明显的东西。

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;
}

有什么建议吗?

【问题讨论】:

  • 好的..我已经能够清理代码很多..(甚至切换回一组简单的 If 语句)只有当 Twitter 和 Facebook 都处于活动状态时才会出现问题。似乎 Twitter 发帖速度如此之快,并且在我的帐户上交叉发布到 Facebook...此时我得到了屏幕锁定。

标签: facebook twitter switch-statement social ios6.1


【解决方案1】:

好的..我发现我复制了这条线 tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter]; 所以这导致了问题......

【讨论】:

    猜你喜欢
    • 2017-02-12
    • 2015-04-29
    • 1970-01-01
    • 2014-02-27
    • 1970-01-01
    • 1970-01-01
    • 2018-10-13
    • 1970-01-01
    • 2017-12-08
    相关资源
    最近更新 更多