您的位置:首页 > 产品设计 > UI/UE

UITableView 的一些小知识

2013-07-19 00:19 155 查看
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{

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: