UITableView 的一些小知识

本文介绍了UITableView中UITableViewCell的各种样式定制方法,包括选择样式、附件样式、分隔线样式等,并详细讲解了如何通过实现代理方法来响应Cell的点击及编辑事件。

typedef enum {
    UITableViewCellSelectionStyleNone,
    UITableViewCellSelectionStyleBlue,
    UITableViewCellSelectionStyleGray
} UITableViewCellSelectionStyle
//cell右边按钮格式
typedef enum {
    UITableViewCellAccessoryNone,                   // don't show any accessory view
    UITableViewCellAccessoryDisclosureIndicator,    // regular chevron. doesn't track
    UITableViewCellAccessoryDetailDisclosureButton, // blue button w/ chevron. tracks
    UITableViewCellAccessoryCheckmark               // checkmark. doesn't track
} UITableViewCellAccessoryType
//是否加换行线
typedef enum {
    UITableViewCellSeparatorStyleNone,
    UITableViewCellSeparatorStyleSingleLine
} UITableViewCellSeparatorStyle//改变换行线颜色


1.点击某一个cell后,将会进入另一个View,返回又回到原始View的最顶端,怎么样才能还返回在点击之前的那个位置呢?

NSIndexPath *ip = [ NSIndexPath  indexPathForRow:row  inSection:section ];

[TopicsTable  selectRowAtIndexPath: ip  animated: YES  scrollPosition : UITableViewScrollPositionNone ];

2.选中Cell响应事件

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

    [tableView  deselectRowAtIndexPath:indexPath  animated:YES];  //选中后的返现颜色即刻消失

}

3.在程序中,有时候会不想让用户去点击某一行,可以这样做:

- (NSIndexPath *)tableView :(UITableView *)tableView  willSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSUInteger  row = [indexPath row];

    if( row == 0)  return nil;  //阻止选中第一行

    return  indexPath;

}

4.滑动cell是否出现del按钮

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{

    

}

5.编辑状态

- (void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

    [topicsTable setContentSize:CGSizeMake(0,controller.promiseNum * 44)];

}

6.右侧添加一个索引表

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableVIew{


}

7.返回标题section标题内容

- (NSString *)tableView:(UITableView *)tableView titleForHeardInSection:(NSInteger)section{

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值