UITableView属性方法使用大全

 

//设置分割线颜色

[self.left_tableView setSeparatorColor:[UIColor blackColor]];

 

代理方法:使用前记得绑定delegate与datasource

//UITableView返回行数 section判断不同分区返回不同的行数

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

 //设置行高

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

//设置tableViewcell返回数据

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

//根据xib 获取cellfangshi  imgTableViewcell 是你自定义的cell 的名字  

NSArray * arr=[[NSBundle mainBundle] loadNibNamed:@"imgTableViewCell" owner:nil options:nil];

cell=[arr lastObject];

// 设置cell选中时cell 的颜色

cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame] ;

 cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:6/255.0 green:120/255.0 blue:169/255.0 alpha:1];

//UItableView 返回几个区

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

// 设置区头高度

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

//设置区头样式 返回一个 设计好的 UIView 做为区头样式

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

//UITableview 区头简单返回字符串

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

//设置选中事件

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

 

 

新手上路~请多多指教  

转载于:https://www.cnblogs.com/mengxz0626/p/4612015.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值