Мне нужен пример или пояснения о том, как заполнить 2 вида таблиц, которые находятся на одном и том же представлении. Мне нужно понять метод cellForRowAtIndexPath, может ли кто-нибудь предоставить мне пример того, как должен выглядеть код?2 tableview на одном виде
Я имею в виду, как определить, что идет, какой вид таблицы?
Благодаря
Ниже мой метод cellForRowAtIndexPath:
// 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...
// Set up the cell
MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
if (tableView == radios_tv) { //radio_tv is an IBOutleet UITableView
sqlClass *aRadio = (sqlClass *)[appDelegate.array_radios objectAtIndex:indexPath.row];
[cell setText:aRadio.r_name];
return cell;
}
if (tableView == presets_tv) { //preset_tv is an IBOutlet UITableView
}
}
и эй vikingsegundo, теперь мне нужно удалить ячейку, которая находится на моем классе TableViewController, как мне это сделать? Я объясню, вот мой код:
- (void)tableView:(UITableView *)tv commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if(editingStyle == UITableViewCellEditingStyleDelete) {
//Get the object to delete from the array.
Coffee *coffeeObj = [appDelegate.coffeeArray objectAtIndex:indexPath.row];
[appDelegate removeCoffee:coffeeObj];
//Delete the object from the table.
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
Поскольку мы поставили разные контроллеры, как мы должны двигаться дальше этой линии? Должен ли я помещать tableViewController вместо «self»?
//Delete the object from the table.
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
и как мы это делаем? Что вы подразумеваете под контролем? Извините, я довольно новичок: s – awlcs
Я ищу пример прямо сейчас. пожалуйста, оставайтесь с нами :) – vikingosegundo
спасибо: D Я тоже искал пример, но мне не удалось найти :( – awlcs