大佬教程收集整理的这篇文章主要介绍了iphone – UITableView与多个部分,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有arrayOne有3个项目和arrayTwo有4个项目,如何添加和显示它们的部分。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if(section == 0) return resultArray.count; else return resultArray.count; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { NSLog(@"number of Sections"); if(section == 0) return @"Section 1"; if(section == 1) return @"Section 2"; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { NSLog(@"Table Cell Data"); static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reusEIDentifier:CellIdentifier]; } appDelegate = (MultipleDetailViewsWithNavigatorAppDelegate *)[[UIApplication sharedApplication] delegate]; if (indexPath.section==0) { appDelegate = (MultipleDetailViewsWithNavigatorAppDelegate *)[[UIApplication sharedApplication] delegate]; ObjectData *theCellData = [resultArray objectATindex:indexPath.row]; NSString *cellValue =theCellData.category; NSLog(@"Cell Values %@",cellvalue); cell.textLabel.text = cellValue; return cell; } else { ObjectData *theCellData = [resultArray objectATindex:indexPath.row]; NSString *cellValue =theCellData.category; cell.textLabel.text = cellValue; return cell; } }@H_489_10@
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2 ; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section==0) { return [array1 count]; } else{ return [array2 count]; } } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if(section == 0) return @"Section 1"; else return @"Section 2"; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reusEIDentifier:CellIdentifier]; } if (indexPath.section==0) { ObjectData *theCellData = [array1 objectATindex:indexPath.row]; NSString *cellValue =theCellData.category; cell.textLabel.text = cellValue; } else { ObjectData *theCellData = [array2 objectATindex:indexPath.row]; NSString *cellValue =theCellData.category; cell.textLabel.text = cellValue; } return cell; }@H_489_10@
以上是大佬教程为你收集整理的iphone – UITableView与多个部分全部内容,希望文章能够帮你解决iphone – UITableView与多个部分所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。