我现在正在尝试开发类似iPhone短信应用中的原生聊天功能。我已按照本指南进行操作:https://github.com/HansPinckaers/GrowingTextView如何创建一个TextView,根据文本的大小来缩放高度。
当然我想将它与我现有的故事板内置的UIViewController(这是一个tableView)集成,而不是像本教程中的代码一样自定义一个新的:https://github.com/HansPinckaers/GrowingTextView/blob/master/example/Classes/GrowingTextViewExampleViewController.m
- (void)loadView {
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view.backgroundColor = [UIColor colorWithRed:219.0f/255.0f green:226.0f/255.0f blue:237.0f/255.0f alpha:1];
.......................................... etc
[self.view addSubview:containerView];
...........................................etc
}
现在,如果我想将故事板上的self.view = [[UIView alloc]代码替换为self.view = my viewController,我应该输入什么?我试图删除代码:
//self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
但是我在尝试添加子视图代码时遇到错误的访问错误[self.view addSubview:containerView];到故事板中的UIViewController,因为如果没有设置其他东西,self.view应该引用故事板?它设置为自定义的UIView代码时有效:
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view.backgroundColor = [UIColor colorWithRed:219.0f/255.0f green:226.0f/255.0f blue:237.0f/255.0f alpha:1];
所以...总而言之,我如何在storyBoard中将subView(containerView)添加到我现有的UIViewController中?这也是我的错误访问错误的图片:http://tinypic.com/view.php?pic=21acqvb&s=6