我想用戶點擊表格行然後用戶將轉到其他頁面。該頁面具有故事板ID「其他視圖」和恢復ID「其他視圖」。 但我不能去旨意視圖客觀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