테이블 뷰 셀을 선택할 때 뷰 컨트롤러를 푸시할 수 없습니다. (Can't push my view controller when I select a table view cell)


문제 설명

테이블 뷰 셀을 선택할 때 뷰 컨트롤러를 푸시할 수 없습니다. (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.

enter image description here

And then drag with right click of mouse to your current controller and make it "root view controller" just like below:

enter image description here

Build and run your app.

방법 2:

make sure "self.navigationController" is not nil and "vc" is not nil

(by Hongxu JinJaimishtrandy)

참조 문서

  1. Can't push my view controller when I select a table view cell (CC BY‑SA 2.5/3.0/4.0)

#uinavigationcontroller #uitableview #objective-c #iOS






관련 질문

세로에서 가로로 회전할 때 UIBarButtonItem 크기를 변경하는 방법은 무엇입니까? (how to change the UIBarButtonItem size when rotate from the portrait to landscape?)

performSegueWithIdentifier는 식별자 오류가 있는 segue를 생성하지 않습니다. (performSegueWithIdentifier produce no segue with identifier error)

UIAlertController는 leftBarButtonItem을 아래로 이동합니다. (UIAlertController moves leftBarButtonItem down)

현재 모달 보기는 탐색 스택에서 탐색 모음을 숨깁니다. (present modal view hides the navigation bar in navigation stack)

테이블 뷰 셀을 선택할 때 뷰 컨트롤러를 푸시할 수 없습니다. (Can't push my view controller when I select a table view cell)

프로그래밍 방식으로 탐색 컨트롤러의 초기 viewController 설정(레이어 SDK) (Set initial viewController in Navigation controller programmatically (Layer SDK))

UIViewController 유형의 표현식으로 UINavigationController를 초기화하는 호환되지 않는 포인터 유형 (Incompatible pointer types initializing UINavigationController with an expression of type UIViewController)

탐색 컨트롤러 도구 모음 크기 및 위치 - iOS Swift (Navigation Controller Toolbar Size & Location - iOS Swift)

Segue는 뒤로 막대 버튼에 데이터를 저장합니다. (Segue saves data on back bar button)

UINavigationController 푸시 전환 중 낮은 프레임 속도 (Low frame rate during UINavigationController push transition)

뷰 컨트롤러에서 탐색 모음의 모양 재설정 (Reset the appearance of navigation bar in a view controller)

탐색 모음 제목 보기 내에서 분할된 제어 스위치를 처리하려고 합니다. (Trying to handle segmented control switch inside of navigation bar title view)







코멘트