Mar*_*k S 61 subview uiview ios
我正在努力将广告提供商集成到我的应用中.我希望在广告显示但广告不完整时,在广告前面放置一条淡化消息.
我创建了一个函数,它在我当前的视图中添加了一个子视图,并试图将它带到前面
[self.view bringSubviewToFront:mySubview]
Run Code Online (Sandbox Code Playgroud)
该功能会在加载广告的通知时触发(通知来自广告提供商的SDK).但是,我的子视图不会在广告前面结束.我认为这是广告提供商故意制作的,但我希望无论如何都这样做.我目前正在与提供商讨论是否允许这样做.但就目前而言,我只是想看看它是否可能.
反正我是否可以强迫我的子视图成为最顶级的视图,这样它就不会受到任何阻碍?
dan*_*kas 165
试试这个:
self.view.layer.zPosition = 1;
Run Code Online (Sandbox Code Playgroud)
jer*_*ere 88
如果广告提供商的视图未添加self.view
到某个类似的内容,该[UIApplication sharedApplication].keyWindow
怎么办?
尝试类似的东西:
[[UIApplication sharedApplication].keyWindow addSubview:yourSubview]
Run Code Online (Sandbox Code Playgroud)
要么
[[UIApplication sharedApplication].keyWindow bringSubviewToFront:yourSubview]
Run Code Online (Sandbox Code Playgroud)
Pau*_*ehn 21
Swift 2版本的Jere答案:
UIApplication.sharedApplication().keyWindow!.bringSubviewToFront(YourViewHere)
Run Code Online (Sandbox Code Playgroud)
斯威夫特3:
UIApplication.shared.keyWindow!.bringSubview(toFront: YourViewHere)
Run Code Online (Sandbox Code Playgroud)
斯威夫特4:
UIApplication.shared.keyWindow!.bringSubviewToFront(YourViewHere)
Run Code Online (Sandbox Code Playgroud)
希望它可以节省10秒!;)
rma*_*ddy 18
我曾经需要这个.我创建了一个自定义UIView
类 - AlwaysOnTopView
.
@interface AlwaysOnTopView : UIView
@end
@implementation AlwaysOnTopView
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (object == self.superview && [keyPath isEqual:@"subviews.@count"]) {
[self.superview bringSubviewToFront:self];
}
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
- (void)willMoveToSuperview:(UIView *)newSuperview {
if (self.superview) {
[self.superview removeObserver:self forKeyPath:@"subviews.@count"];
}
[super willMoveToSuperview:newSuperview];
}
- (void)didMoveToSuperview {
[super didMoveToSuperview];
if (self.superview) {
[self.superview addObserver:self forKeyPath:@"subviews.@count" options:0 context:nil];
}
}
@end
Run Code Online (Sandbox Code Playgroud)
您的观点是否扩展了这个课程.当然,这只能确保子视图高于其所有兄弟视图.
归档时间: |
|
查看次数: |
109758 次 |
最近记录: |