不能改优先级为
UILayoutPriorityRequired (1000)的约束在
heightForRowAtIndexPath没有被正确测量cell的高度时,cellForRowAtIndexPath可能会被不必要的调用,即不可见的cell也会被调用。如果正好数据量很大,会导致性呢个严重下降。present出一个背景可透明的
viewControllerif (IOS_VERSION >= 8.0) { vc.modalPresentationStyle = UIModalPresentationOverCurrentContext; }else{ self.modalPresentationStyle = UIModalPresentationOverFullScreen; } vc.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentViewController:vc animated:YES completion:nil];
NSUInteger无符号整数的-1是一个很大的数值 在与NSInteger做比较时应注意。例:
NSInteger a = 5; NSUInteger b = -1;a<b成立。


Arr.count是无符号的(NSUInteger),跟-1(NSInteger)比较时,会把-1转成NSUInteger,然而NSUInteger不保存负数,-1符号被截断后溢出变成了一个很大的数利用这个特性,以后判断数组下标是否越界时,不用写:
if(index >= 0 && index < arr.count)
直接写这个就好了,一样的效果:
if(index < arr.count)URL编码:
编码URL中的参数部分:
return [str stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];各参数的区别:

编码整个字符串:
return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)str, NULL, (__bridge CFStringRef)@":/?&=;+!@#$()',*", kCFStringEncodingUTF8);
把
cell当sectionHeaderView用, 需要把cell放进一个容器里,否则可能导致no index path for table cell being reused的错误,以及sectionHeaderView在界面上消失.-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"head"]; //把 cell 放进一个容器里再设置为sectionHeaderView UIView *view = [[UIView alloc] initWithFrame:[cell frame]]; cell.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; [view addSubview:cell]; return view; }
可以利用
tableView.backgroundView来做空列表提示等功能给静态
tableView的rightDetail风格的cell上的detailText赋值时, 遇到的一些问题:detailText赋值text为@""或者nil之后,此控件会消失看不见,再赋值也不会出来.detailText赋值attributedText后, 控件大小(宽)没有跟着变.
解决办法: 赋值后刷新
tableView或cell
评论已关闭