首页 UITableView 开发小技巧
文章
取消

UITableView 开发小技巧

  • 隐藏 UITableView的滚动条以及修改滚动条的颜色
 //隐藏滚动条
  self.tableView.showsVerticalScrollIndicator = NO;
  //修改颜色
  self.tableView.indicatorStyle=UIScrollViewIndicatorStyleWhite;
  • UITableView 上拉时多显示一部分区域
  //设置 TableView 的底部 View
   UIView *footView=[UIView new];
      footView.frame=CGRectMake(0, 0, 320, 30);
   self.tableV.tableFooterView=footView;
  • 刷新局部多个 cell
  NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
  
    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil]
               withRowAnimation:UITableViewRowAnimationFade];
  • 局部刷新 section
  NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];

  NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];
  [self.tableView reloadSections:indexSet
         withRowAnimation:UITableViewRowAnimationFade];
  • 滑动至任意位置
         NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
         [self.tableview scrollToRowAtIndexPath:indexPath
                               atScrollPosition:UITableViewScrollPositionBottom
                                       animated:YES];
  • TableView 按钮高亮状态延迟解决方案
        self.tableView.delaysContentTouches = NO;

   for (UIView *currentView in self.tableView.subviews){

       if([currentView isKindOfClass:[UIScrollView class]]){
       
          ((UIScrollView *)currentView).delaysContentTouches = NO;
          break;
          
       }
   }
本文由作者按照 CC BY 4.0 进行授权

-

NSString 相关笔记