2013-03-25 2 views
14
- (IBAction)submitButtonClicked:(id)sender{ 
    NSLog(@"here"); 
    SuccessOrFailViewController *sfvc = [[SuccessOrFailViewController alloc] init]; 
    [self presentViewController:sfvc animated:NO completion:NULL]; 
} 

사용자가 앱의 제출 버튼을 클릭 할 때 새 페이지를 열려고합니다. 그러나 이것은 아무 것도없는 완전히 검은 색 화면을 엽니 다. 어떻게하면 viewController를 대신 열 수 있습니까?presentViewController 검은 페이지를 보여줍니다

답변

41
당신은 사용자 인터페이스의 펜촉의 이름을 입력하지 않는

:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
SuccessOrFailViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"SuccessOrFailViewController"]; 
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen]; 
[self presentModalViewController:sfvc animated:YES]; 
+0

누락 "="이 한 Statment에서 : SuccessOrFailViewController * sfvc [스토리 instantiateViewControllerWithIdentifier "SuccessOrFailViewController"@]; – mikemike396

+0

답변을 수정하고 수정했습니다. Thx – Lefteris

+0

스토리 보드를 사용한 방법은 매우 멋집니다! 탁자 – pash3r

1

스토리 보드 iOS7에

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
SuccessOrFailViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"SuccessOrFailViewController"]; 
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen]; 
[self presentViewController:sfvc animated:YES completion:nil]; 
6

경우 : 스토리 보드를 들어

SuccessOrFailViewController *sfvc = [[SuccessOrFailViewController alloc] initWithNibName:@"SuccessOrFailViewController" bundle:nil]; 
[self presentViewController:sfvc animated:NO completion:NULL]; 

이 갈 수있는 방법입니다 스위프트

var next = self.storyboard?.instantiateViewControllerWithIdentifier("DashboardController") as! DashboardController 
self.presentViewController(next, animated: true, completion: nil) 

StoryBoard에서의 ViewController StoryBoard Id을 설정하는 것을 잊지 마세요 ->identity inspector

3

Incase의 다른 사람이 ... 당신이보기에 self.view.backgroundColor = UIColor.clearColor()을 설정하지 않았는지 확인이 표시 될 수 있도록이 그것을 해결 찾습니다 나를.

+0

이봐,이게 내 문제를 해결해 줬어. 감사. 솔루션은 단순한 것이어야하지만, 정확히 무엇이 문제인지는 알지 못합니다. – mythicalcoder

+0

맞아요.'modal Presentation Style'에 관심을 가져야합니다. https://developer.apple.com/reference/uikit/uiviewcontroller/1621355-modalpresentationstyle – onmyway133

1

Storyboard에서보기 컨트롤러를 추가 및 삭제하고 View Controller를 최신 스토리 보드 식별자로 업데이트하는 것을 잊어 버렸습니다. 프로그래밍 새로운 뷰 컨트롤러로 이동하는 경우 예를 들어

,이 같은 (코드의 주 식별자 "FirstUserVC"입니다) :

let firstLaunch = (storyboard?.instantiateViewControllerWithIdentifier("FirstUserVC"))! as UIViewController 
self.navigationController?.pushViewController(firstLaunch, animated: true) 

다음은 스토리 보드 ID가 인터페이스 빌더에서 확인 스토리 ID에 대한 아이덴티티에 나열된 FirstUserVC와 같이 설정 : enter image description here

관련 문제