views:

61

answers:

2

Hi,

I have a tabbar controller and on touching a button in one of view's navigation right button i want to load a (nav controller + view )on top of it. The view which is on the top of it is semi transparent and i should be able to see the content in the tabbar controller.

I tried using the [self.tabbarcontroller.view addSubview:navController];

I worked perfectly and it is working fine. But when i tried to do the same thing in landscape view it is just occupying half the screen. what should be done ? is there a way to fix this issue

can i use the window to load my new view ? will it occupy the entire screen ? i tried autoresize masks and there is no effect

+1  A: 

What is the bounds of the navController/tabbarcontroller? Are you setting correctly to that of the window?

You can output it easily:

NSLog(@"navController bounds: %@",NSStringFromCGRect(navController.view.bounds));
christo16
it is 0,0 320,460. I actually manually set it as 0,0,460,320 using drawRect method and frame property of uiview. It has no effect. :(
thndrkiss
i set the bounds and frame of the view after adding to the navigation controller. That helped me. Your idea to watch the bounds really helped me. Thanks a lot.
thndrkiss
A: 

Do you mean addSubview:navController.view? I didn't think you could treat view controllers as views.

In general, you need to be careful when using UIViewController outside of the framework-managed classes. UIKit automatically handles stuff like viewWillAppear/autorotation for the view controllers that it knows about, but it doesn't know about the VCs whose views you randomly add as subviews.

EDIT: If all you require is that it appears to be transparent, you can use something like

UIGraphicsBeginImageContextWithOptions(tabBarController.view.size, 0, 0);
[tabBarController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

and then use img as the view background. It won't animate the stuff in the background, but provided you don't need this, it's much faster than having lots of transparent views stacked on top of each other.

tc.