简体   繁体   English

Xcode在整个屏幕上添加子视图

[英]Xcode Adding Subview on entire screen above everything

I want to use addSubview method to add new view on my screen. 我想使用addSubview方法在我的屏幕上添加新视图。 However, new view must also include navigation bar etc. which means it should include entire screen. 但是,新视图还必须包含导航栏等,这意味着它应包括整个屏幕。 What should i do? 我该怎么办?

Whenever i try to addSubview it always shows new view under navigation bar. 每当我尝试添加子视图时,它总是在导航栏下显示新视图。

I don't want to use pushViewController or presentModelViewController because new added view will be low opacity and i can see background but i do not want to interact with background objects like bar buttons table etc. Sorry for english, i hope, i clearly told what problem is. 我不想使用pushViewController或presentModelViewController,因为新添加的视图将是低不透明度,我可以看到背景,但我不想与酒吧按钮表等背景对象进行交互。抱歉英语,我希望,我明确告诉了什么问题是。

Just set the frame property of the view you add before, and set it with screen bounds. 只需设置之前添加的视图的frame属性,并使用屏幕边界设置它。

[myView setFrame:[[UIScreen mainScreen] bounds];
[self.navigationController.view addSubview:myView];

If you want to disable interaction with the navigation bar : 如果要禁用与导航栏的交互:

[self.navigationController.navigationBar setUserInteractionEnabled:NO];

您可以查看在根窗口上方添加另一个UIWindow。

when I tried doing the navigationController.view addSubview, it wouldn't cover my tab bar so I did the following with my app delegate's window: 当我尝试使用navigationController.view addSubview时,它不会覆盖我的标签栏,所以我使用我的app delegate窗口执行了以下操作:

[self.window addSubview:myView];

if you need access to your appDelegate from another class, you'd just import your application delegate and call it from that. 如果您需要从另一个类访问您的appDelegate,您只需导入您的应用程序委托并从中调用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM