0
self.tablePicture阵列似乎只重复第一个项目“star_white.png”其他颜色等与self.tableData数组,并不明白为什么......任何想法为什么?数组只重复第一个项目与其他阵列
- (id)init
{
self = [super init];
if (self) {
// Custom initialization
self.tableData = [NSArray arrayWithObjects:@"continent", @"region", @"country", @"city", @"town", @"district", @"borough", nil];
self.tablePicture = [NSArray arrayWithObjects:@"star_white.png", @"star_blue.png", @"star_red.png", @"star_green.png", @"star_purple.png", @"star_orange.png", @"star_black.png", nil];
CGRect frame = self.view.bounds;
frame.size.height -= 100;
self.tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
[self.tableView setBackgroundColor:[UIColor clearColor]];
[self.tableView setDataSource:self];
[self.tableView setDelegate:self];
[self.tableView setScrollEnabled:NO];
[self.view addSubview:self.tableView];
}
return self;
}
和
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"ITSectionIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
// modify cell
NSString *name = [self.tableData objectAtIndex:indexPath.section];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
[cell.textLabel setText:name];
cell.imageView.image = [UIImage imageNamed:[tablePicture objectAtIndex:indexPath.row]];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
仍然没有运气:( – CraigBellamy 2012-02-07 22:30:50
是它创造足够的细胞和你创建不同的部分,或者他们都在一个 部分?意思是所有的单元格,但只是会有相同的图像star_white.png。 – Jaybit 2012-02-07 22:36:29
对不起,我正在创建多个部分,每个tableData和tablePicture .. – CraigBellamy 2012-02-07 22:37:47