0

을 작동하지 않습니다 :아이폰 OS과 pushViewController 내가 탐색 컨트롤러, 뷰 컨트롤러, 내 모든 스토리 보드에서 만든 테이블보기를

enter image description here

당신이 테이블보기에서 특정 행을 터치 그것은 새로운 컨트롤러를 내비게이션 컨트롤러로 밀어 넣어야하지만, 아무 일도 일어나지 않습니다. 당신이에서보기를 밀어되도록

enter image description here

- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { 
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; 

UINavigationController *controller = (UINavigationController*)[mainStoryboard 
                   instantiateViewControllerWithIdentifier: @"dbNav"]; 

SubLevelViewController *slController = [[SubLevelViewController alloc] initWithStyle:UITableViewStylePlain]; 
[controller pushViewController: slController animated: YES]; 
} 
+0

'컨트롤러'는 'nil'입니까? – Larme

+0

아니요, 컨트롤러가 0이 아닙니다. – user3925803

답변

2

- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { 

    UINavigationController *controller = self.navigationController; 

    SubLevelViewController *slController = [[SubLevelViewController alloc] initWithStyle:UITableViewStylePlain]; 
    [controller pushViewController: slController animated: YES]; 
} 
기본적으로

instantiateViewControllerWithIdentifier 시도 지정된 뷰 컨트롤러 당신이 그것을 호출 할 때마다 새로운 인스턴스를 생성 : 여기에 코드입니다 다른 표시된 탐색 컨트롤러

+0

효과가있었습니다. 감사! – user3925803

0

이것은 나를 위해 일했습니다. 인덱스 경로를 정의해야합니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    ServicesModel *service = [services objectAtIndex:indexPath.row]; 
    ServiceViewController *serviceViewController = [self.storyboard  instantiateViewControllerWithIdentifier:@"ServiceView"]; 
    serviceViewController.serviceModel = service; 
    [self.serviceController pushViewController:serviceViewController animated:YES]; 
}