我試圖在ContainerView中顯示ViewController。 如果我使用內部ViewController(與ContainerView在同一個項目中的源代碼),它將按預期工作。 所以我從另一個項目中使用ViewController它不會顯示。 我已經在外部ViewController的viewDidLoad中實現了一個AlertDialog,並且將顯示AlterDialog。在ContainerView中顯示ViewController
編輯: 我發現我必須將外部ViewController的.xib添加到Build Phase中的Copy Bundle Resouces(在主項目中)。 有沒有解決這個問題的另一種方法?
代碼:
#import "ViewController.h"
#import "Utilities/Form.h"
#import "TestForm.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize ListContainer = _ListContainer;
- (void)viewDidLoad {
[super viewDidLoad];
@try {
Form *viewConnection = [[Form alloc]init];
viewConnection.view.frame = _ListContainer.bounds;
[_ListContainer addSubview:viewConnection.view];
[self addChildViewController:viewConnection];
[viewConnection didMoveToParentViewController:self];
}
@catch (NSException *exception) {
}
@finally {
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
感謝您的快速回復,但你的解決方案也不會太出。我問自己,如果我使用內部表單,爲什麼它可以工作,但是如果我使用外部表單,它不起作用 – bengt91
「內部表單」? 「外部形式」?這些術語意味着什麼? –
內部形式是我的主要項目中的視圖控制器外部的一個是在包含的框架項目內的視圖控制器 – bengt91