[英]adding subview of another class
iv created a class with xib so i can access it throughout my app. iv用xib创建了一个类,这样我就可以在我的整个应用程序中访问它。 The class basically holds a nib with has three uiviews and a few buttons buttons+labels.
该类基本上拥有一个笔尖,该笔尖具有三个uiviews和一些按钮button + labels。 Now im calling class A (the one with 3 view etc) from classB but every time i addsubview to self.view nothing happens.
现在我从类B调用类A(具有3个视图的类),但是每次我将subview添加到self.view时,都不会发生。 any help appreciated.
任何帮助表示赞赏。
ive done the following in class Bh 我在Bh类中完成了以下工作
#import "PlayResultViewController.h"
PlayResultViewController *playResultViewController;
in classB.m 在班级
//viewdidload
playResultViewController = [[PlayResultViewController alloc]init];
//some random method
[placeholderView addSubview:playResultViewController.loseView];
您需要告诉它要加载哪个笔尖。
playResultViewController = [[PlayResultViewController alloc] initWithNibName:@"Mynib" bundle:nil];
You are missing the initWithNibName to start with, here are some examples 您缺少开始使用的initWithNibName,这是一些示例
With a Navigation controller u can use 通过导航控制器,您可以使用
BViewController *bController = [[BViewController alloc] initWithNibName:@"BViewController" bundle:nil];
[self.navigationController pushViewController:bController animated:YES];
[bController release];
without UInavigation controller you can test with 没有UInavigation控制器,您可以测试
BViewController *bController = [[BViewController alloc] initWithNibName:@"BViewController" bundle:nil];
self.view = bController;
// or alternatively self.view = bController.view;
[bController release];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.