Массив 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;
}