Roman Simenok
Roman Simenok

Reputation: 560

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

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 :)

Upvotes: 0

Views: 106

Answers (3)

Dharmbir Singh
Dharmbir Singh

Reputation: 17535

You need to make property like this in .h file

@property (strong, nonatomic)MyViewNavigationController *tableVC;

and then do it in .m file

tableVC = [[MyViewNavigationController alloc] initWithTableSize:CGSizeMake(380, 600)];
tableVC.delegate = self;
[self.view addSubview:tableVC.view];

Upvotes: 1

Chris
Chris

Reputation: 489

change

[self.view addSubview:tableVC];

to

[self.view addSubview:tableVC.view];

Upvotes: 1

Manish Agrawal
Manish Agrawal

Reputation: 11026

you can only add the layout of type UIView or layout inherited from UIView, so change the code as given below.

MyViewNavigationController *tableVC = [[MyViewNavigationController alloc] initWithTableSize:CGSizeMake(380, 600)];
tableVC.delegate = self;
[self.view addSubview:tableVC.view];

Upvotes: 1

Related Questions