码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2015-10-10 12:17:03      阅读:283      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!