cell的setSeparatorInset 時閃爍
在做項(xiàng)目時真機(jī)測試時遇到了一個問題,當(dāng)點(diǎn)擊HOME鍵后,重新打開軟件,屏幕會閃一下,然后沒任何報錯,懷疑時獲取完數(shù)據(jù)后是不是Tableview刷新導(dǎo)致的,然后調(diào)試了不是,后來想到如果在刷新時創(chuàng)建新的視圖有可能也會導(dǎo)致刷新,后來發(fā)現(xiàn)也不是,然后將代碼一部分一部分篩查才發(fā)現(xiàn)在cellForRowAtIndexPath方法中創(chuàng)建cell的時候加了[cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, MAXFLOAT)];去掉就不會閃爍了.具體原因我也沒弄懂,估計(jì)在設(shè)置cell縮進(jìn)的時候進(jìn)行頁面刷新了,如果有知道的朋友可以給我留言,大家學(xué)習(xí)一下.當(dāng)然
iOS 7下
想要設(shè)置cell的分割線縮進(jìn)為0,在iOS7中只用簡單的設(shè)置cell的separatorInset = UIEdgeInsetZero;
iOS 8下
在iOS8下,上面的方法就不行啦,
//Setup your cell margins:
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
// Remove seperator inset
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
// Prevent the cell from inheriting the Table View's margin settings
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
[cell setPreservesSuperviewLayoutMargins:NO];
}
// Explictly set your cell's layout margins
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}