- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; // Do any additional setup after loading the vIEw from its nib. headVIEwController *headVIEwController = [[headVIEwController alloc] initWithNibname:@"headVIEwController" bundle:nil]; UIVIEw *vIEw = [[UIVIEw alloc] initWithFrame:CGRectMake(0,320,120)]; [vIEw addSubvIEw:headVIEwController.vew]; [self.vIEw addSubvIEw:vIEw];}
headVIEwController.h:
@interface headVIEwController : UIVIEwController{ IBOutlet UIVIEw *vIEw;}@property (nonatomic,retain)IBOutlet UIVIEw *vIEw;@end
然后我将视图连接到文件的所有者.
而且我看不到headVIEwController.vIEw.
解决方法 首先,您不需要在headVIEwController类中定义视图插座.它自动从UIVIEwController超类继承.然后,我建议您直接将headVIEwController的视图添加到当前视图中.例如.
- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; // Do any additional setup after loading the vIEw from its nib. headVIEwController *headVIEwController = [[headVIEwController alloc] initWithNibname:@"headVIEwController" bundle:nil]; headVIEwController.vIEw.frame = CGRectMake(0,120); [self.vIEw addSubvIEw:headVIEwController.vIEw];}
但是,如果您使用ARC(自动引用计数),则headVIEwController实例可能会在vIEwDIDLoad方法结束后释放.将该实例分配给您当前正在显示的控制器中的局部变量很方便(并且我说这是必须的).这样,您可以在以后需要时处理其视图的组件,实例将被保留,其他所有内容都将完美运行.你应该有类似的东西:
- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; // Do any additional setup after loading the vIEw from its nib. self.headVIEwController = [[headVIEwController alloc] initWithNibname:@"headVIEwController" bundle:nil]; headVIEwController.vIEw.frame = CGRectMake(0,120); [self.vIEw addSubvIEw:headVIEwController.vIEw];}
和
@interface MyController () @property (nonatomic,strong) headVIEwController *headVIEwController;@end
在.m类实现文件开头的隐藏接口定义中.
总结以上是内存溢出为你收集整理的ios – UIView addSubview并且不显示子视图全部内容,希望文章能够帮你解决ios – UIView addSubview并且不显示子视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)