views:

124

answers:

3

I have something like this:

myViewController = [[MyViewController alloc] initWithNibName:@"MyView" bundle:nil];
[mainCanvas addSubview: myViewController.view];
self.view = mainCanvas;

It will added on the position (0, 0), but I want to add on 0,100 or somewhere else, how can I do so? thank you.

+5  A: 

Set the frame property on the sub view.

Gary
May u provide a sample?
Ted Wong
How about you go and do some investigation and see if you can figure it out, it's very simple and I'm sure you can google up some samples. If you get stuck come back with your sample code and I'll gladly help.
Gary
+1  A: 

I do agree with Gary that this sort of question should be easily ansered with a little Google-fu but hey I'm in a good mood today.

Something like this

myViewController = [[MyViewController alloc] initWithNibName:@"MyView" bundle:nil];
myViewController.frame = CGRectMake(0, 100, myViewController.view.frame.size.width, myViewController.view.frame.size.height);
[mainCanvas addSubview: myViewController.view];
self.view = mainCanvas;
acqu13sce
+1  A: 

In addition to setting the frame property, you can also set the center property of a view.

Dave DeLong