Я хочу, чтобы пользователь нажал строку таблицы, после чего пользователь перейдет на другую страницу. На странице есть идентификатор раскадровки «Другой вид» и идентификатор восстановления «Другой вид». Но я не могу пойти замыслил зренияЦель c - щелкнуть строку таблицы и перейти на другую страницу
Это мой код:
- (UITableViewCell *)tableView:(UITableView *)tabel cellForRowAtIndexPath:(NSIndexPath *)indeksBaris
{
static NSString *simpleTableIdentifier = @"TampilanCell";
TabelBeritaCell *cell = (TabelBeritaCell *)[tabel dequeueReusableCellWithIdentifier:simpleTableIdentifier];
NSLog(@"nilai : %d", indeksBaris.row);
//detecting NIB of table view
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TableView" owner:self options:nil];
cell = [nib objectAtIndex:0];
//Go To View Controller which have identifier "Other View"
UIViewController *otherViewCon;
otherViewCon = [self.storyboard instantiateViewControllerWithIdentifier:@"Other View"];
[self.navigationController pushViewController:otherViewCon animated:YES];
cell.judulBerita.text = [listBerita objectAtIndex:indeksBaris.row];
return cell;
}
Этот код не работает:
UIViewController *otherViewCon;
otherViewCon = [self.storyboard instantiateViewControllerWithIdentifier:@"Other View"];
[self.navigationController pushViewController:otherViewCon animated:YES];
ОБНОВЛЕНО меня вставить новый код. Я использовать метод didSelectRowAtIndexPath, но он не работает:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *otherViewCon;
otherViewCon = [self.storyboard instantiateViewControllerWithIdentifier:@"Other View"];
[self.navigationController pushViewController:otherViewCon animated:YES];
}
показать код метода didSelectRowAtInedxPath –
Нет, я не использовал этот метод. Я попробую сначала ... –
Почему бы вам не попробовать то, что я написал в своем ответе: '[self performSegueWithIdentifier: @" ShowDetail "sender: tableView];' Вам не нужно создавать новый UIViewController – Jessica