【问题标题】:Touches on a subview outside the frame of its superview触及其父视图框架之外的子视图
【发布时间】:2014-10-07 15:21:15
【问题描述】:

需要帮助。

在superview框架外创建一个菜单。 menu=[[MyView alloc]initWithFrame:CGRectMake(0, -100, 320, 100)];

当菜单移动到屏幕上时,superview 也会移动。

    -(void)openMenu:(UIView *)view
{

    [UIView animateWithDuration:0.5
                          delay:0.1
                        options: UIViewAnimationOptionBeginFromCurrentState
                     animations:^
     {
         CGRect frame = menu.frame;
         CGRect viewFrame = view.frame; //superview

         frame.origin.y=-80;
         viewFrame.origin.y=65;

         menu.frame = frame;
         view.frame = viewFrame;

     }
                     completion:^(BOOL finished)
     {

     }];}

菜单有 5 个按钮。

问题在于它们不响应触摸事件。我读到有必要替换:hitTest:withEvent:,但我不明白该怎么做。

谢谢!

【问题讨论】:

  • 你想在动画状态下触摸它吗?
  • 不,之后。动画停止时。
  • 您能解释一下您的需求吗?什么是菜单,什么是视图

标签: ios objective-c


【解决方案1】:

我找到了解决方案。需要增加窗口边界。将行 view.frame 替换为 view.bounds。问题是触摸事件在窗口范围之外没有响应。

谢谢大家!

附:对不起我的英语!

【讨论】:

    猜你喜欢
    • 2014-02-15
    • 2012-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多