2 개의 뷰 컨트롤러가있는 앱을 개발할 수 있는지 알고 싶습니다. 스토리 보드를 사용하는 경우 솔루션을 찾을 수 없지만 일부 링크를 통과했습니다. 이미 rooviewcontroller를 가지고 있다면 어떻게 제거하고 rootviewcontroller로 다른 뷰를 추가 할 수 있습니까? 한 번에스토리 보드를 사용하여 IOS 어플리케이션에 2 개의 rootviewcontrollers를 추가 할 수 있습니다.
2
A
답변
3
있다. rootViewController를 변경하려는 장소/액션에 아래 코드를 추가하기 만하면됩니다. AnotherRootViewController의
//First dismiss your currently loaded ViewController
[self dismissViewControllerAnimated:YES completion:nil];
//Get the keyWindow of the app
UIWindow *window = [[UIApplication sharedApplication]keyWindow];
NSString *identifier = @"Your_Identifier_Name_For_ViewController";// this is the identifier name(Storyboard ID)
// of the AnotherRootViewController
// which you have to set in your Storyboard
// as shown in the figure.
//Now create an object of the AnotherRootViewController
AnotherRootViewController *newRootViewController = [self.storyboard instantiateViewControllerWithIdentifier:identifier];
//Finally set your newRootViewController
[window setRootViewController:newRootViewController];
그리고 수 있도록 설정은 그림과 스토리 보드 :
가 당신의 요구 사항을 만족하는 경우 알려주세요.
2
당신은 그렇게 할 수 있습니다 응용 프로그램에서 하나의 rootviewController, 당신은 다음을 사용하여 직접 대체 할 수
, AppDelegate에 방법에
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
YourVC *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"YourVC"];
self.window.rootViewController = rootViewController;
,
두 개의보기 컨트롤러가있는 경우 "루트"도 아닙니다. – trojanfoe
죄송합니다. u를 얻을 수 없었습니다. –
중요하지 않습니다. 이제 질문을 수정 한 것이 좋습니다. – trojanfoe