当前位置:编程学习 > wap >>

UITableView 的一些小知识

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{

}

 

补充:移动开发 , IOS ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,