我正在构建一个带有样式tableview Grouped的UITableView
,并在方法框UITableViewCell
上给出一个间隙(左边距)
- (void)setFrame:(CGRect)frame {
if(IOS_7){ //above ios 6
CGFloat gap = 10.0f;
frame.origin.x += gap;
frame.size.width -= gap*2;
}
[super setFrame:frame];
}
然后在5s后,我做了调用方法
[_table beginUpdates];
[_table endUpdates];
结果like this。
右边的差距是我的差距的两倍=(差距* 2)
此问题仅适用于ios 8,
在uitableviewcell中是iOS 8调用两次setFrame吗? 以及如何解决它?
请注意:
- 我已尝试使用CGRectMake(0.0f, frame.origin.y, [UIScreen mainScreen].bounds.size.width, frame.size.height);
重置帧,但如果我使用ipad与左侧菜单一侧,它不能解决我的问题,
- 不使用自定义单元格(仅使用默认的uitableviewcell)
答案 0 :(得分:0)
您正在设置错误的帧。你应该这样做:
- (void)setFrame:(CGRect)frame {
if(IOS_7){ //above ios 6
CGFloat gap = 10.0f;
frame.origin.x += gap;
frame.size.width -= gap*2;
[super setFrame: frame];
}
}