热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

我可以让一个UIPresentationController在PresentingViewController上有userInteractionEnabled吗?

如何解决《我可以让一个UIPresentationController在PresentingViewController上有userInteractionEnabled吗?》经验,为你挑选了1个好方法。

我正在为iPhone和iPad的通用应用程序构建自定义GUI.在iPad上,它主要依赖于"sideViews"等实用程序,如内容操作,detailInformation等(想想一个高级的SplitView).从视觉的角度来看,新的UIPresentationController让我能够呈现这些"sideViews"(并且不使用dimmedView),并且实现起来非常简单,可以构建和维护,同时仍然可以很好地与故事板集成.但是,当presentViewController可见时,我需要能够操作presentViewController的内容.所以我的问题是,我可以在呈现sideViews时在presentViewController上设置userInteractionEnabled(或类似)吗?



1> Glen Low..:

UIPresentationController插入其容器视图作为窗口子视图的呈现视图上方,从而外部任何触摸呈现视图由容器视图被困,从不使它的呈现视图.

修复方法是在容器视图上插入一个视图,该视图通过触摸传递到呈现视图.您可以将其用作调光视图或将其backgroundColor设置[UIColor clearColor]为完全透明的视图.在演示控制器代码中设置passthrough视图.

@interface IVPasserView : UIView

@property (strong, nonatomic) NSArray* passthroughViews;

@end

@implementation IVPasserView

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    UIView* hit = [super hitTest:point withEvent:event];
    if (hit == self)
        for (UIView* passthroughView in _passthroughViews)
        {
            hit = [passthroughView hitTest:[self convertPoint:point toView:passthroughView]
                                 withEvent:event];
            if (hit)
                break;
        }
    return hit;
}

@end

注意:虽然这违反了-[UIView hitTest:withEvent:]它没有返回子视图的精神,但实际上这是系统标准如何UIPopoverPresentationController处理它.如果在passthroughViews那里设置属性,容器视图会hitTest:withEvent:以直通视图响应,即使它们不是superview/subview!因此,它可能会在下一个iOS版本中存活下来.


推荐阅读
author-avatar
Angle健少
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有