[英]how add view to subview?
I try to show in one view other, but it doesn't work 我尝试以一种视图显示其他视图,但这不起作用
my views 我的看法
General 一般
@interface BaseViewController : UIViewController<UIPopoverControllerDelegate, DatePickerDelegate, AddScriptPopoverViewDelegate>
2nd 第二名
@interface MyViewController : BaseViewController<UniversalViewNavigationDelegate, StarsSizeViewDelegate, SelectPopoverViewDelegate, MyTableViewDelegate>
3rd 第三名
@interface MyViewNavigationController : UIViewController<UITabBarDelegate, UISearchBarDelegate, MyTableViewDelegate>
in need to show my third view in second, but when i try in second, in viewDidload 需要在第二个显示我的第三个视图,但是当我尝试第二个显示在viewDidload中
MyViewNavigationController *tableVC = [[MyViewNavigationController alloc] initWithTableSize:CGSizeMake(380, 600)];
tableVC.delegate = self;
[self.view addSubview:tableVC];
last row saing me: 最后一行说我:
Incompatible pointer types sending 'MyViewNavigationController *__strong' to parameter of type 'UIView *'
and crush 粉碎
Help me please :) 请帮帮我 :)
you can only add the layout of type UIView or layout inherited from UIView, so change the code as given below. 您只能添加UIView类型的布局或从UIView继承的布局,因此请更改下面的代码。
MyViewNavigationController *tableVC = [[MyViewNavigationController alloc] initWithTableSize:CGSizeMake(380, 600)];
tableVC.delegate = self;
[self.view addSubview:tableVC.view];
change 更改
[self.view addSubview:tableVC];
to 至
[self.view addSubview:tableVC.view];
You need to make property like this in .h file 您需要在.h文件中设置像这样的属性
@property (strong, nonatomic)MyViewNavigationController *tableVC;
and then do it in .m file 然后在.m文件中执行
tableVC = [[MyViewNavigationController alloc] initWithTableSize:CGSizeMake(380, 600)];
tableVC.delegate = self;
[self.view addSubview:tableVC.view];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.