关于tableviewcell的一些必备常识

1.设置tableview的背景颜色当设置tableview.backgroundcolor无效时,这样设置:

    UIView *view    = [[UIView alloc] initWithFrame:_tableView.frame];

      view.backgroundColor    = UIColorFromRGB(0x1f2f4b);

     _tableView.backgroundView   = view;  

2.想设置cell选中时不想要样式,应该这样设置:

      UIView* view = [[UIView alloc]initWithFrame:cell.frame];

        view.backgroundColor    = [UIColor clearColor];

        cell.selectedBackgroundView     = view;

3.设置多选:

   _tableView.allowsMultipleSelectionDuringEditing = YES;

4.当不想看到tableview没有cell的地方的分割线时,应该这样设置:

   _tableView.tableFooterView  = [[UITableView alloc] init];

5.当为tableview加入手势如tap时,datasource的didselect那个方法事件会被覆盖,此时需要实现tap的代理方法去判断移除:

  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

  {

      NSString *className = NSStringFromClass([touch.view class]);

      // 若为UITableViewCellContentView(即点击了tableViewCell),则不截获Touch事件

      if ([className isEqualToString:@"UITableViewCellContentView"]) {  

          return  NO;

      }

      return  YES;

  }

6.隐藏tableviewcell的分割线:

   _tableView.separatorStyle   = UITableViewCellSeparatorStyleNone;

  本人在编程方面的时间可能不长,写的博客可能不怎么好,如对本人的博客有异议的,欢迎来给出意见。

posted @ 2016-09-01 11:48  文艺IT者  阅读(213)  评论(0编辑  收藏  举报