0
나는 (처음으로 소개 뷰 컨트롤러를 인스턴스화 한 다음 실제 응용 프로그램보기 컨트롤러를 나중에 주보기 컨트롤러 컨테이너를 구현하려고합니다. 그러나 나는 그것을 작동시키지 못하고 정말로 기본적인 것을 놓치고 있다고 느낍니다. 다음과 같은 인터페이스를 사용하여자식보기 대신 자식 호출 부모보기 컨트롤러
: 다음 initWithFrame에서 도입보기의 소개 뷰 컨트롤러로드
@interface ViewControllerMain : UIViewController
@property (strong, nonatomic) ViewControllerIntroduction *viewControllerIntroduction;
@end
그리고
@implementation ViewControllerMain
- (void)loadView
{
// Instantiate the view controller for the adventure view
self.viewControllerIntroduction = [ [ [ ViewControllerIntroduction alloc] init ] autorelease ];
}
- (void)viewDidLoad
{
[ super viewDidLoad ];
// Instantiate the view controller for the introduction view
[ self addChildViewController: self.viewControllerIntroduction ];
[ self.view addSubview: self.viewControllerIntroduction.view ];
[ self.viewControllerIntroduction didMoveToParentViewController: self ];
}
@end
의 다음 구현 나는 addSubView 문을지나 단계, 그것을 addChildViewController 문으로 되돌아갑니다.
나는 몇 시간 동안이 문제를 해결하기 위해 노력해 왔으며 어떤 도움을 주시면 감사하겠습니다.
OMG! 그것은 효과가 있었고 ... 많은 사람들이 참으로 감사합니다 .- – Roddy
-loadView 메소드를 오버라이드하여 뭔가를 놓쳤습니까? 이것은 뷰 컨트롤러에 실제보기가 포함되어있는 경우에만보기 컨트롤러에서 -loadView를 오버라이드한다는 것을 명시 적으로 나타 냅니까? – Roddy
'self.view'는 UIViewController 클래스의'-loadView' 메소드에서 자동으로 초기화됩니다 ... 당신의 서브 클래스에서 그것을 오버라이드한다면 명시 적으로 초기화해야합니다'self.view = [[UIView alloc] initWithFrame ...] '. 또한, 컨테이너 뷰 컨트롤러를 구축하고 있더라도 뷰가 있습니다. – graver