我已經得到以下代碼。該陣列由XML建立起來的,所以每個節點都有一個標題(這將是該部分的標題)和文本iPhone:陣列中的表格行/區段 - 設置陣列中的區段和行數據量
因此,每個節點都有1個單元和1題(將在細胞本身去)
- (NSInteger)
numberOfSectionsInTableView:(UITableView *)tableView {
return [arrySummaryTitle count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
AssessObject *newObj1 = [[AssessObject alloc] init];
newObj1=[totalArray objectAtIndex:indexPath.row];
cell.textLabel.text = newObj1.routeImage;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.numberOfLines = 0;
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0];
return cell;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return [arrySummaryTitle objectAtIndex:section];
}
我真的很努力地做的是循環通過單元格和節標題循環通過newObj1.routeImage並有一個數組中的單元格文本和單元格部分?我甚至在努力解釋哈哈
陣列被建立起來,如:
章節標題,章節標題,章節標題等
同樣的文本,他們都在newObj1是.whatever
所以我需要它,這樣的表建立這樣的:
[Section Header]
[Section Text]
[Section Header]
[Section Text]
等
有道理?湯姆
警告:您正在泄漏內存。 'AssessObject * newObj1 = [[AssessObject alloc] init]'之後';' ,你應該在指向一個新的值之前調用[newObj1 release]。你也可以在零發起'newObj1'... – Vinzzz