문제 설명
테이블 뷰 셀을 선택할 때 뷰 컨트롤러를 푸시할 수 없습니다. (Can't push my view controller when I select a table view cell)
저는 Objective‑C를 사용하고 있습니다. 테이블 뷰 셀을 선택할 때 새 vier 컨트롤러를 푸시하고 싶습니다. 이것은 내 코드입니다.
‑ (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
detailViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"detailVC"];
//something
[self.navigationController pushViewController:vc animated:YES];
}
내 스토리보드에 상세 보기 컨트롤러가 있고 스토리보드 ID "deatilVC"를 설정합니다. 그러나 테이블 보기 셀을 선택하면 시뮬레이터가 멈춥니다. 누군가 나를 도울 수 있습니까?
참조 솔루션
방법 1:
Take one navigation controller and make the current controller from where your didSelectRowAtIndexPath will call to it's root controller in storyboard. Check the following example.
And then drag with right click of mouse to your current controller and make it "root view controller" just like below:
Build and run your app.
방법 2:
make sure "self.navigationController" is not nil and "vc" is not nil
(by Hongxu Jin、Jaimish、trandy)