編集: この質問は、Interface Builder とクラスのプロパティがどのように機能するかを理解していないことが原因です。
self.mySubView = anoterhView;
設定できるように設定できないのはなぜself.view = anotherView;
ですか?
## .h
@interface TestController : UIViewController {
IBOutlet UIView *mySubView;
}
@property (nonatomic, retain) IBOutlet UIView *mySubView;
##.m
@implements TestController
@synthesize mySubView;
- (void)viewDidLoad {
AnotherController *anotherController = [[AnotherController alloc] initWithNibName:nil bundle:nil];
anotherView = anotherController.view;
// if i do
self.view = anotherView;
// result: replaces whole view with anotherView
// if i instead do
self.mySubView = anotherView;
// result: no change at all
// or if i instead do:
[self.mySubView addSubview:anotherView];
// result: mySubView is now displaying anotherView
}
注: 私は interfacebuilder を使用しています。self.view と self.mySubView addSubview: が正常に動作しているため、すべてが正常に接続されていると確信しています..