01 关于convertRect:toView:的理解
image.pngA为B的父控件,B是添加到A视图上的。C视图没特别限制,可为nil.
02 关于图片压缩需要宽高等比计算的问题
image.png03 tableHeaderView 使用autolayout 自适应高度
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.bottom.equalTo(self.view);
}];
self.tableView.tableHeaderView = self.headerView;
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.tableView.mas_top);
make.width.mas_equalTo(SCREENWIDTH);
}];
}
04 计算多行文本高度的方式,采用 UILabel 的 -sizeThatFits:方法
UILabel *label = [[UILabel alloc]init];
label.numberOfLines = 0;
label.lineBreakMode = NSLineBreakByWordWrapping;
label.text = text;
label.font = [UIFont systemFontOfSize:16];
CGSize labelSize = [label sizeThatFits:CGSizeMake(kScreenWidth-32, MAXFLOAT)];
CGFloat height = ceil(labelSize.height) + 1;
相关链接:https://blog.csdn.net/smilebigdear/article/details/70054561
05 区分NSMutableArray的三个方法
- replaceObjectAtIndex:withObject:
- insertObject:atIndex:
- addObject:
self.arrTitles = @[@"可使用",@"不可用"].mutableCopy;
if (listModel.useTotalNum > 0) {
NSString *useStr = [NSString stringWithFormat:@"可使用(%ld)",listModel.useTotalNum];
[self.arrTitles replaceObjectAtIndex:0 withObject:useStr];
}
if (listModel.unuseTotalNum > 0) {
NSString *unuseStr = [NSString stringWithFormat:@"不可用(%ld)",listModel.unuseTotalNum];
[self.arrTitles replaceObjectAtIndex:1 withObject:unuseStr];
}
网友评论