开发者

loading a view on top of tabbarcontroller

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜