首页 > 移动平台 > 详细

application is modifying the autolayout engine from a background thread解决方案

时间:2015-10-10 12:14:33      阅读:217      评论:0      收藏:0      [点我收藏+]
NSURLSession *session = [NSURLSession sharedSession];
    __weak id safeSelf = self;
    NSURLSessionDataTask *task = [session dataTaskWithRequest:req completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        self.webData = data;
        if (self.webData) {
            // 如果获取到了数据
            NSXMLParser *paser = [[NSXMLParser alloc]initWithData:self.webData];
            paser.delegate = self;
            [paser parse];
        }
        
        if ([self.parseResults isEqualToString:@"false"]) {
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"登录失败" message:@"帐号密码错误" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *action = [UIAlertAction actionWithTitle:@"oops" style:UIAlertActionStyleDefault handler:nil];
            [alert addAction:action];
            //dispatch_async(dispatch_get_main_queue(), ^{
                [self presentViewController:alert animated:YES completion:nil];
            //});
            
        }
        

    }];
    [task resume];
    
[self presentViewController:alert animated:YES completion:nil]语句报错,信息为:

application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes.  This will cause an exception in a future release.

解决方法:

  dispatch_async(dispatch_get_main_queue(), ^{
                [self presentViewController:alert animated:YES completion:nil];
            });

 

 

application is modifying the autolayout engine from a background thread解决方案

原文:http://www.cnblogs.com/somebod-Y/p/4866231.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!