change size of viewcontroller - iphone sdk

1.6k views Asked by At

I am using custom tabbar and navigation controller. When i add any subview it works fine but when I try to push a view of what ever size it automatically changes its size to full screen and overlaps the tabbar.

couponDetailsVC *myVC = [[couponDetailsVC alloc] initWithNibName:@"couponDetailsVC" bundle:[NSBundle mainBundle]];
        //[self.view addSubview:myVC.view];
[self.navigationController pushViewController:myVC animated:YES];

Can anyone please tell me how to resize the viewcontroller I also tried the following but no success:

- (void)viewWillAppear:(BOOL)animated {

CGSize size = {320, 300}; // size of view in popover
self.contentSizeForViewInPopover = size;

[super viewWillAppear:animated];

}

Also tried the above in viewDidLoad

Also tried changing the size of view controller after pushing it like:

myVC.view.frame = CGRectMake(0, 0, 320, 411);

How to achieve this functionality?

2

There are 2 answers

1
Vin On

If the ViewController's view is overlapping your tabbar, perhaps you are not following the correct view hierarchy. TabBar controller is a container controller that would 'contain' UIViewControllers' views. Generally UIViewControllers' views are intended to be shown in full screen only.

0
Pras On

Hope this snippet will solve your issue..

myVC.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

myVC.view.contentMode = UIViewContentModeScaleToFill;