最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

iOS11 SectionHeader 胡亂移動且滑動時出現(xiàn)重復內(nèi)容的解決方法

 更新時間:2017年11月06日 11:59:57   作者:Macocoa  
這篇文章主要介紹了iOS11 SectionHeader 胡亂移動且滑動時出現(xiàn)重復內(nèi)容的解決方法,需要的朋友可以參考下

升級到iOS 11后,痛苦的事情多起來了,以前版本沒有的出現(xiàn)問題的代碼,經(jīng)過Xcode 9一編譯,千萬草泥馬奔騰而過;

今天碰到一個奇葩問題,直接進入主題:

問題描述:

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
  return 12;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
  UIView* headerSection_V = [[UIView alloc]initWithFrame:CGRectMake(ZERODIS, ZERODIS, SCREEN_WIDTH, 12)];
  [headerSection_V setBackgroundColor:COLOR_3];
  return headerSection_V;
}

1-   headerView 會錯亂移動, 且調(diào)整tableView 的style也沒有效果;

2- 滑動tableView的時候, 貌似底部又多出一個圖層tableView,重復了tableViewCell的內(nèi)容;

3-  以下代碼無效:(當然tableVIew 懶加載的時候 還有相應代碼設置cell分割線的偏移)

/**
 * 解決cell分割線距離兩邊12 居中對齊
 */
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
  if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
    [cell setSeparatorInset:UIEdgeInsetsMake(ZERODIS, 12, ZERODIS, 12)];
  }
  if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
    [cell setLayoutMargins:UIEdgeInsetsMake(ZERODIS, 12, ZERODIS, 12)];
  }
}

最后排查發(fā)現(xiàn):

舊代碼使用了xib但是又沒有用xib的tableView,  tableView又是自己代碼生成的, 把xib刪除之后,就OK了;

PS:下面通過實例代碼給大家分享UITableView SectionHeader 自定義section的頭部。

具體代碼如下所示:

//自定義section的頭部
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
  UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(10, 0, 300, 30)];//創(chuàng)建一個視圖
  UIImageView *headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, 300, 30)];
  UIImage *image = [UIImage imageNamed:@"4-2.png"];
  [headerImageView setImage:image];
  [headerView addSubview:headerImageView];
  [headerImageView release];
  NSString *createTime = [self.keysArray objectAtIndex:section];
  createTime = [createTime stringByReplacingCharactersInRange:NSMakeRange(4, 1) withString:@"-"];
  createTime = [createTime stringByReplacingCharactersInRange:NSMakeRange(7, 1) withString:@"-"];
  UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 5, 150, 20)];
  headerLabel.backgroundColor = [UIColor clearColor];
  headerLabel.font = [UIFont boldSystemFontOfSize:15.0];
  headerLabel.textColor = [UIColor blueColor];
  headerLabel.text = createTime;
  [headerView addSubview:headerLabel];
  [headerLabel release];
  return headerView;
}

總結(jié)

以上所述是小編給大家介紹的iOS11 SectionHeader 胡亂移動且滑動時出現(xiàn)重復內(nèi)容的解決方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論

盐亭县| 溧阳市| 周至县| 扶风县| 嘉善县| 株洲县| 彭阳县| 巴林右旗| 疏附县| 信宜市| 新干县| 民勤县| 祁门县| 怀集县| 年辖:市辖区| 曲水县| 天台县| 都昌县| 九龙城区| 丰都县| 彭阳县| 浮梁县| 惠来县| 兴城市| 武隆县| 酒泉市| 武功县| 柳林县| 思南县| 安西县| 栾城县| 措勤县| 珲春市| 延寿县| 江华| 辽源市| 阜阳市| 稷山县| 临猗县| 秀山| 廉江市|