将子视图置于所有其他视图的前面 [英] Bringing a subview to be in front of all other views

查看:101
本文介绍了将子视图置于所有其他视图的前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力将广告提供商集成到我的应用中.我希望在广告显示但完全失败后在广告前放置淡入淡出的消息.

I am working on integrating an ad provider into my app currently. I wish to place a fading message in front of the ad when the ad displays but have been completely unsuccessful.

我制作了一个函数,在当前视图中添加了一个子视图,并尝试使用

I made a function which adds a subview to my current view and tries to bring it to the front using

[self.view bringSubviewToFront:mySubview]

该函数在广告已加载的通知上触发(该通知来自广告提供者的SDK).但是,我的子视图不会出现在广告的前面.我认为广告提供商故意使这变得困难,但是无论如何,我都希望做到这一点.我目前正在与提供商讨论是否可以允许这样做.但是暂时,我只是想看看是否有可能.

The function fires on notification that the ad loaded (the notification is from the adprovider's SDK). However, my subview does not end up in front of the ad. I imagine this is made purposely difficult by the ad provider, but I wish to do it regardless. I am currently discussing with the provider whether or not this can be allowed. But for the time being, I just want to see if it's even possible.

无论如何,我是否可以强制我的子视图成为最顶层的视图,以使它不会被任何东西遮挡?

Is there anyway I can force a subview of mine to be the top-most view such that it will not be obstructed by anything?

推荐答案

如果广告提供商的视图未添加到self.view而是添加到类似[UIApplication sharedApplication].keyWindow的视图怎么办?

What if the ad provider's view is not added to self.view but to something like [UIApplication sharedApplication].keyWindow?

尝试类似的东西:

[[UIApplication sharedApplication].keyWindow addSubview:yourSubview]

[[UIApplication sharedApplication].keyWindow bringSubviewToFront:yourSubview]

这篇关于将子视图置于所有其他视图的前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆