ios – 发送推文后App冻结

栏目: IOS · 发布时间: 6年前

内容简介:翻译自:https://stackoverflow.com/questions/12800489/app-freezes-after-sending-tweet
嗨,我在iOS应用程序中有两个UIButton.一个是发布到Twitter,第二个是发布到Facebook. Facebook按钮工作得很好但是推文给我留下了一些问题,推文表将打开填充文本,但需要两次点击取消按钮才能解除.如果我点击发送,将发送推文并且表单被解雇,但我的应用程序冻结并变得无法响应.我已经包含了两位代码
- (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);

}];
}

您正在展示ViewController“myTweet”

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

但是你的completionHandler中没有解雇……声明

[self dismissViewControllerAnimated:YES completion:nil];

翻译自:https://stackoverflow.com/questions/12800489/app-freezes-after-sending-tweet


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

GUI设计禁忌2.0

GUI设计禁忌2.0

Jeff Johnson / 盛海艳 等 / 机械工业出版社 / 2008 / 49.00元

本书描述软件开发人员在设计图形用户界面(GUI)时经常犯的“禁忌”,并提出避免这些错误的基本原则和理论依据。本书将GUI禁忌分为7种类型:GUI控件禁忌、导航禁忌、文字禁忌、图形设计和布局禁忌、交互禁忌、响应性禁忌以及管理禁忌,并分别进行详述。 本书编排独特,条理清晰,针对性极强,是不可多得的GUI设计优秀资源。本书适合软件开发人员、web站点设计人员、开发经理、用户界面设计人员等阅读。一起来看看 《GUI设计禁忌2.0》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

html转js在线工具
html转js在线工具

html转js在线工具