tags:

views:

31

answers:

1

Hello,

Consider this as my SubView

UIView *subViewObj;

and this as MainView

UIView *mainViewObj;

i need to make MainView as root View can i don it in this way?

[mainViewObj addSubview:subViewObj];

is this correct?i need to do it programitically, without using Interface builder.

A: 

Yes addSubview: is correct.

Andrew
ok... should i everytime do this before using mainViewObj or subViewObj? CGRect cgRect = CGRectMake(0.0,0.0,480,320); mainViewObj = [[UIVIew alloc]initWithFrame:cgRect];mainViewObj.autoResizeSubviews = YES;
suse
It depends. I do not know how mainViewObj was created, but if you wanted subViewObj to fill the entire bounds of its superview (mainViewObj), you would set subViewObj's frame.size to that of mainViewObj and set subViewObj.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight. `autoresizesSubviews` is YES by default so you need not set it every time.
Andrew