iOS - BUG

作者: CDLOG | 来源:发表于2018-08-17 09:29 被阅读2次

总是要第二次加载才正确的控件,尝试延迟加载

Table切换数据源往上走了

[self.view showLoadMessageAtCenter:@"加载中"];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [self.view hide];
            [self.billTable reloadData];
        });

Sdweb 加载网络图片,tableview显示 bug

在回调中设置控件的大小,高度约束,延迟加载(转圈),,并刷新 tableview

-(void)setSection2
{
     CGSize contentSize =  [self setMultiLineWithLable:self.dailyPriceContent];
    NSURL *url = [NSURL URLWithString:self.priceModel.image.validImageUrl_big_1080];


  [self.view showLoadMessageAtCenter:@"加载中..."];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.dailyPriceImage sd_setImageWithURL:url completed:^(UIImage *image, NSError *error, EMSDImageCacheType cacheType, NSURL *imageURL) {
            //        [self.view hide];
            if (image==nil) {
                CGSize size =CGSizeMake(0, contentSize.height +  self. section2HeadTitleLable.frame.size.height + 10+21 + 14  + 23 + 15)  ;
//                 CGFloat height = screenWidth/ (image.size.width/image.size.height)
                //self.section2Size真实高度返回全局变量
                self.section2Size = size;
                //        表格刷新真实高度
                [self.detailTable reloadData];
                [self.view showError:@"加载失败"];
                [self.view hide];
                return ;
            }
            //根据原始图片比例计算控件高度
            self.dailyPriceImage.bounds =CGRectMake(0, 0,self.dailyPriceImage.image.size.width, screenWidth/ (image.size.width/image.size.height)) ;
            //根据原始图片比例计算约束高度
            self.dailyPriceImageHeight.constant = screenWidth/ (image.size.width/image.size.height);
            [self.detailTable layoutIfNeeded];
            
            CGSize size =CGSizeMake(0, contentSize.height + screenWidth/ (image.size.width/image.size.height)+ self. section2HeadTitleLable.frame.size.height + 10+21 + 14  + 23 + 15)  ;
            //self.section2Size真实高度返回全局变量
            self.section2Size = size;
            //        表格刷新真实高度
            dispatch_queue_t queue = dispatch_queue_create("refrensh", DISPATCH_QUEUE_CONCURRENT);
            
            dispatch_barrier_sync(queue, ^{
                [self.detailTable reloadData];
            });
            [self.detailTable hide];
        }];
    });
   
}

点击事件不响应,给控件添加手势

-(void)loadGesture{
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapmethod:)];
    [self.detailTable addGestureRecognizer:tap];
}
-(void) tapmethod:(UITapGestureRecognizer *) tap{
    self.dailyPriceHistoryTable.hidden = YES;
}

刷新没有刷新表格数据

数据加载错误 ,没有刷新表格

image 高度自动适应不正确,要修改高度约束后刷新

屏幕高度的计算:screenWidth/ (image.size.width/image.size.height

异步的网络请求

1, 在网络请求体内进行逻辑处理
2, 在网络请求体内进行代理调用

服务器返回布尔值

必须转换了再使用,不然始终是yes
_pwdDone = [self.profileCache[@"pwdDone"] boolValue];

Lable居中只显示一行

不居中,设置左右间距

加载tableView的headView适配压缩问题

不要用headview,直接用cell
也可以判断系统版本,加载不同的高度

sendDetailsHeadView * headView = [[NSBundle mainBundle]loadNibNamed:@"sendDetailsHeadView" owner:nil options:nil].lastObject;
    NSString *version = [UIDevice currentDevice].systemVersion;
    if (version.doubleValue >= 11.0) {
        headView.bounds = CGRectMake(0, 0, screenWidth-30, 270);
    } else {
        headView.bounds = CGRectMake(0, 0, screenWidth-30, 370);
    }

相关文章

网友评论

      本文标题:iOS - BUG

      本文链接:https://www.haomeiwen.com/subject/uhqzbftx.html