tableView

来源:互联网 发布:eplan软件界面 编辑:程序博客网 时间:2024/05/17 23:58
// 索引的集合- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{    return _sectionIndexArray;}// 索引滚动的 section- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{    return [kSectionIndexs rangeOfString:title].location;}// section count- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{    return [_sectionIndexArray count];}// section//- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section//{//    if (section == 0) {//        return @"分组";//    }//    else {//        return [_sectionIndexArray objectAtIndex:section];//    }//}- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{    if (section == 0)        return  [_groupDataArray count] ? tableView.sectionHeaderHeight : 0;        else        return [[_personDataArray objectAtIndex:section] count] ? tableView.sectionHeaderHeight : 0;}- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{    SCSectionHeaderView *sectionHeaderView = [[SCSectionHeaderView alloc] init];        if (section == 0) {        sectionHeaderView.contentLabel.text = @"分组";    }    else {        sectionHeaderView.contentLabel.text = [[_personDataArray objectAtIndex:section] count] ? [[kSectionIndexs substringFromIndex:section] substringToIndex:1] : nil;    }        return [sectionHeaderView autorelease];}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    if (section == 0) {        return [_groupDataArray count];    }    else {        return [[_personDataArray objectAtIndex:section] count];    }}- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{    return 60;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    if (indexPath.section == 0) {        static NSString *cellID = @"SCGroupTable";        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];        if (!cell) {            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];        }                if (_groupDataArray.count > 0) {            cell.textLabel.text = [(SCGroupTable *)[_groupDataArray objectAtIndex:indexPath.row] groupName];                    }        return cell;    }    else {        static NSString *cellID = @"SCCustomerTable";        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];        if (!cell) {            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];        }                if ([(NSArray *)[_personDataArray objectAtIndex:indexPath.section] count]) {             cell.textLabel.text = [(SCCustomerTable *)[[_personDataArray objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] customerName];            NSLog(@"....");        }               return cell;    }}- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{    NSLog(@"");}

0 0
原创粉丝点击