Эй, ребята, я внедряю Table View в свой проект.Сначала я заполнил свою таблицу, затем мне удалось успешно создать 4 категории и дать количество строк в каждой из этих категорий, но вот моя проблема.Первая категория (которая имеет 7 объектов) работает нормально, когда для каждой информации в этой категории открываются свои собственные файлы пера.Но во второй категории, в которой есть 3 объекта, 3 объекта фактически открывают файлы пера из первой категории, а это не то, что мне нужно.Я создал и назначил каждому объекту в своей таблице просмотр своих собственных файлов пера, но, как я уже сказал, объекты из второй, а также третьей и четвертой категорий открывают файлы пера из первой категории.Вот мой код, как я разделяю объекты в моем табличном представлении:
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 4;
}
// Category
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
if (section == 0) return @"Category 1";
if (section == 1) return @"Category 2";
if (section == 2) return @"Category 3";
if (section == 3) return @"Category 4";
return @"Other";
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
if (section == 0) return 7;
if (section == 1) return 3;
if (section == 2) return 6;
if (section == 3) return 5;
return 0;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
NSUInteger row = [indexPath row];
if ( indexPath.section == 1 ) row += 7;
if ( indexPath.section == 2 ) row += 10;
if ( indexPath.section == 3 ) row += 16;
if ( indexPath.section == 4 ) row += 21;
cell.textLabel.text = [glossaryArray objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
и открываю каждую ячейку:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if ([[glossaryArray objectAtIndex:indexPath.row] isEqual:@"First View Controller"]) {
FirstViewController *firstVC = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
[self.navigationController firstVC animated:YES];
[firstVC release];
}
else if ([[glossaryArray objectAtIndex:indexPath.row] isEqual:@"Second View Controller"]) {
SecondViewController *secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondViewController animated:YES];
[secondViewController release];
}
else if (...
Так что почти все мои файлы пера открывают каждое представлениено, опять же, проблема в том, что они не открывают свои собственные представления, они открывают файлы пера из первой категории, которая является неправильными файлами пера.Итак, я надеюсь, что кто-то может помочь мне разобраться в этой проблеме, спасибо