하나의 뷰 안에 여러 UIViewController 객체를 표시하려고합니다. 당분간 나는 앱이로드 될 때 하나의 UIViewController 객체를 표시하려고합니다. 그러나 자식보기 컨트롤러 내부에 레이블을 표시해야하는 반면 응용 프로그램 화면은 비어있는 것처럼 보입니다. 여기 iOS : UIViewController가 스토리 보드를 사용하는 다른 UIViewController를 표시하지 않습니다.
내가 무슨 짓을 :ParentViewController.h
#import <UIKit/UIKit.h>
@interface ParentViewController : UIViewController
{
UIViewController *child1Controller;
UIViewController *child2Controller;
}
@end
에게
#import "ParentViewController.h"
#import "Child1Controller.h"
#import "Child2Controller.h"
@interface ParentViewController()
@end
@implementation ParentViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { ... }
- (void)viewDidLoad
{
child2Controller = [[Child2Controller alloc] init];
[self.view addSubview:child2Controller.view];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewDidUnload { ... }
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { ... }
@end
ParentViewController.m
그리고 인터페이스 빌더에서 스토리 보드에- 3보기를 추가 컨트롤러
- Child2Controller 개체에있는 ParentViewController, Child1Controller & Child2Controller
- 에 클래스를 할당하고 View 내부에 UILabel을 추가했습니다. Child2Controller.h에서
- 는 UILabel의를 위해 함께 IBOutlet을 정의하고 프로젝트의 Info.plist는
가 뭔가 이상 그리워 했 메인 스토리 보드 파일을 설정 마침내 Child2Controller.m에서 동일한에 대한
+1 사실 참 잘 작동합니다. 그러나 내가 알아 내고 싶은 것은 코드/흐름에서 제가 잘못 게시 한 것입니다. – vikmalhotra
@ShiVik Child2Controller는 어떻습니까? xib로로드 되었습니까? 아니면 * loadView * 메서드를 재정의 했습니까? –
아니요 새로운 xib 파일이나 'loadView'를 만들지 않았습니다. 내가 한 일은 스토리 보드에 UIViewController를 추가하고 아이디 속성 검사기에서 사용자 정의 클래스를 Child2Controller로 지정했습니다. – vikmalhotra