调整帧大小后禁用Uiviews按钮中的用户操作



我确实有一个Uiview子类,我们称其为popupupview。在此弹出窗口内,我确实有一个带有自定义UIVIEW的NavigationBar和其中的Uibutton (2)。另外,在弹出窗口内有一个Uibutton (1)

PopupView
  - UIButton (1)
  - UINavigationBar
    - UINavigationItem
      - UIBarButtonItem
        - UIView
          - UIButton (2)

uinavigationbar疯狂中这个uibutton的原因是因为我可以在uibutton中使用capinsets进行背景图像,但不能用于uibarbuttonitem。

我的问题:

我使用Uiview Animation和调整弹出式视频大小,在动画完成后,我无法单击此Uiview中的按钮

[UIView animateWithDuration:0.4f delay:0.0f options:UIViewAnimationCurveEaseOut animations:^{
        CGRect popupFrame = self.frame;
        popupFrame.size.height += 140.0f;
        popupFrame.origin.y = floorf(popupFrame.origin.y - (140.0f / 2));
        self.frame = popupFrame;
    } completion:^(BOOL finished) {
}];

如果我不使用Uiview动画并直接设置新帧,这也会发生这种情况。同样,我是通过单击或直接在其ViewController中的viewDidLoad上调整大小的大小。

有什么想法为什么会发生?

heer是您recursiveDescription输出的相关部分:

|    | <UIView: 0xaac0480; frame = (0 0; 320 568); tag = 23945; layer = <CALayer: 0xaac04e0>>
|    |    | <MJPopupBackgroundView: 0xaac0710; frame = (0 0; 320 568); tag = 23943; layer = <CALayer: 0xaac07c0>>
|    |    | <UIButton: 0xaac0aa0; frame = (0 0; 320 568); opaque = NO; layer = <CALayer: 0xaac0b60>>
|    |    | <UIView: 0x9d6fea0; frame = (10 204; 300 160); autoresize = W+H; tag = 23942; layer = <CALayer: 0x9d6ff50>>
|    |    |    | <MoviePopupView: 0xab1aaa0; frame = (0 -70; 300 300); clipsToBounds = YES; layer = <CALayer: 0xab1a070>>

0xaac视图覆盖屏幕。

在0xAAC视图中,0x9d6视图的高度为160点,并在0xaac视图中垂直居中。

在0x9d6视图中,0xAB1 MoviePopupView的高度为300点,并且(其Y来源为-70)的中心是"内部" 0x9d6视图,但溢出了0x9d6视图的顶部和底部边缘。<<<<<<<<<<<<<<<<<<<<<<<<<</p>

clipsToBounds属性的默认值为否,因此0x9d6 View不会在视觉上剪辑其0xab1子视图的内容。因此,按钮在屏幕上仍然可见。

但是,按测试始终剪辑到视图的边界。因此,当您尝试触摸其中一个按钮时,命中位于0x9d6视图的边界之外(其高度为160点)。0x9d6视图在到达MoviePopupView或下面的按钮之前拒绝触摸。

hitTest:withEvent:文档中提到了这一点:

位于接收器范围之外的点从未被报告为命中,即使它们实际上位于接收器的一个子视图中。如果当前视图的clipsToBounds属性设置为NO,并且受影响的子视图扩展到视图的边界。

,可能会发生这种情况。

,由于我们看不到按钮的位置,因此不可能确定说明,但是如果您给包含按钮的Uiview给出背景颜色(或将其设置为剪辑子视图),您可能会发现调整大小会导致您的按钮在框架外面,从而使它们无法拼合。

最新更新