#pragma mark ---- TableView开始 ////////////////////////////////////////// // Customize the number of sections in the table view. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [JDList count]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 88; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"ListCell"; ListCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[ListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell = [[[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil] lastObject]; return cell; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 40)]; label.text = @"fsdfs"; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; [cell.contentView addSubview:label]; [label release]; } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { } #pragma mark ---- TableView结束
/////分页 - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row==(m_tieziDetailList.count-1)&&isEndList==NO) { iListCountNum++; NSLog(@"%d",indexPath.row); NSThread *InitThread = [[NSThread alloc]initWithTarget:self selector:@selector(GetNewListThread:) object:tableView]; [InitThread start]; } } -(void)GetNewListThread:(id)sender { NSMutableArray *array = [g_json GetJIKETieZiHFListFromServerWithtopicId:topic_idNode.topic_id m_pageSize:20 m_pageNum:iListCountNum]; if(array.count == 0) { isEndList = YES; } else { isEndList=NO; } [m_tieziDetailList addObjectsFromArray:array]; [self performSelectorOnMainThread:@selector(ReLoadTableData:) withObject:(UITableView*)sender waitUntilDone:NO]; } -(void)ReLoadTableData:(id)sender { UITableView *table = (UITableView*)sender; [table reloadData]; }
不等高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath]; return cell.frame.size.height; }
直接cell.xib
NSArray* nibView = [[NSBundle mainBundle] loadNibNamed:@"ManagerTileCell" owner:nil options:nil]; UITableViewCell *cell = [nibView objectAtIndex:0]; cell.selectionStyle = UITableViewCellSelectionStyleNone;
设置Cell不可点击
self.m_table.allowsSelection =NO;
设置Cell点击后不变色
cell.selectionStyle =UITableViewCellSelectionStyleNone;