在 tabbarcontroller 顶部加载视图
我有一个标签栏控制器,在触摸视图导航右键之一中的按钮时,我想在其顶部加载一个(导航控制器+视图)。其顶部的视图是半透明的,我应该能够看到选项卡栏控制器中的内容。
我尝试使用 [self.tabbarcontroller.view addSubview:navController];
我工作得很好,而且工作得很好。但是当我尝试在横向视图中做同样的事情时,它只占据了屏幕的一半。应该做什么?有没有办法解决这个问题
我可以使用窗口加载我的新视图吗?它会占据整个屏幕吗?我尝试了自动调整蒙版大小,但没有效果
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
navController/tabbarcontroller 的边界是什么?您是否正确设置了窗口的设置?
您可以轻松输出它:
What is the bounds of the navController/tabbarcontroller? Are you setting correctly to that of the window?
You can output it easily:
您的意思是
addSubview:navController.view
吗?我不认为你可以将视图控制器视为视图。一般来说,在框架管理的类之外使用 UIViewController 时需要小心。 UIKit 自动处理它所知道的视图控制器的 viewWillAppear/autorotation 等内容,但它不知道您随机添加其视图作为子视图的 VC。
编辑:如果您只需要它看起来是透明的,您可以使用类似的东西
,然后使用 img 作为视图背景。它不会为背景中的内容设置动画,但如果您不需要这样做,它比将大量透明视图堆叠在一起要快得多。
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
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.