调整框架大小后禁用uiviews按钮中的用户操作 [英] user action in uiviews buttons disabled after frame resizing

查看:50
本文介绍了调整框架大小后禁用uiviews按钮中的用户操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实有一个UIView子类,我们称其为PopupView.在这个PopupView中,我确实有一个NavigationBar,其中带有一个自定义uiview和一个uibutton (2).另外,在PopupView内部直接有一个UIButton (1).

I do have a UIView subclass, lets call it PopupView. inside this PopupView i do have a NavigationBar with a custom uiview and a uibutton (2) inside it. Also there is a UIButton (1) directly inside the PopupView.

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

在uinavigationbar疯狂中使用此uibutton的原因是因为我可以将Capinsets用于uibutton中的背景图像,但不能用于uibarbuttonitem.

the reason of this uibutton in uinavigationbar crazyness is because i can use capinsets for backgroundimages in a uibutton but not for a uibarbuttonitem.

我的问题:

我使用uiview动画调整PopupView的大小,并且动画完成后,我无法再单击该uiview中的按钮.

i resize the PopupView using uiview animation and after the animation is completed, i'm unable to click the buttons in this uiview anymore.

[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 上调整其大小也没关系.

this also happens if i don't use uiview animations and set the new frame directly. also it doesn't matter if i resize it on a click or directly on viewDidLoad in it's viewController.

为什么会发生这种情况?

Any ideas why this happens?

推荐答案

以下是 recursiveDescription 输出中的相关部分:

Heer's the relevant part of your recursiveDescription output:

|    | <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视图覆盖了屏幕.

The 0xaac view covers the screen.

在0xaac视图内,0x9d6视图的高度为160点,并且在0xaac视图内垂直居中.

Inside the 0xaac view, the 0x9d6 view has a height of 160 points and is centered vertically within the 0xaac view.

在0x9d6视图内,0xab1 MoviePopupView 的高度为300点,并且(其Y原点为-70)居中于"0x9d6视图内",但溢出顶部和底部0x9d6视图的边缘.

Inside the 0x9d6 view, the 0xab1 MoviePopupView has a height of 300 points and (with its Y origin of -70) is centered "inside" the 0x9d6 view, but spills past the top and bottom edges of the 0x9d6 view.

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

The default value of the clipsToBounds property is NO, so the 0x9d6 view doesn't visually clip the contents of its 0xab1 subview. Thus the buttons are still visible on screen.

但是,点击测试始终会限制视图的边界.因此,当您尝试触摸其中一个按钮时,命中点位于0x9d6视图(仅具有160点的高度)的范围之外.0x9d6视图在触摸 MoviePopupView 或它下面的按钮之前会拒绝触摸.

However, hit testing always clips to a view's bounds. So when you try to touch one of the buttons, the hit is outside the bounds of the 0x9d6 view (which only has a height of 160 points). The 0x9d6 view rejects the touch before it gets to the MoviePopupView or the buttons under it.

位于接收者范围之外的点即使实际上位于接收者的子视图之一内,也不会被报告为匹配.如果当前视图的 clipsToBounds 属性设置为 NO ,并且受影响的子视图超出了视图的范围,则会发生这种情况.

Points that lie outside the receiver’s bounds are never reported as hits, even if they actually lie within one of the receiver’s subviews. This can occur if the current view’s clipsToBounds property is set to NO and the affected subview extends beyond the view’s bounds.

这篇关于调整框架大小后禁用uiviews按钮中的用户操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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