2013-10-09 4 views
0

스토리 보드에서 스토리 보드 ID를 사용하여 특정 장면을 동적으로로드하려고합니다. 스토리 보드를 통해 별도의 nib 파일을로드하는 것과 같습니다. 스토리 보드 ID가 "storyid"인 장면이 있습니다. 그럼 내가 그것을로드하려고하지만 그것이로드되면 내 화면에 그 장면을 얻을 수 없습니다. 코드에 오류가 없습니다. 당신이 탐색 컨트롤러에 포함 된 경우스토리 보드를 통해 nib 파일을로드하려면 어떻게해야합니까?

- (IBAction)btnLoadSceneClicked:(id)sender 
{ 
    NSLog(@"btnLoadSceneClicked"); 
    [self.storyboard instantiateViewControllerWithIdentifier:@"storyid"]; 
} 

답변

2
YourViewControllerClass * viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"storyid"]; 
[self presentViewController: animated:YES completion:^{ /* what happens when the viewController is presented */}] 

또한의 ViewController를 밀어 수 있습니다.

[self.navigationController pushViewController:viewController animated:YES]; 
0
- (IBAction)btnLoadSceneClicked:(id)sender 
{ 
    NSLog(@"btnLoadSceneClicked"); 
    YourViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"storyBoardID"]; 
    [viewController.view setFrame:CGRectMake(160, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    [self.view addSubview:viewController.view]; 
    [UIView animateWithDuration:0.50f animations:^{ 
     [viewController.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    } completion:^(BOOL finished) { 
    }]; 
} 
관련 문제