Vitali Eller
Vitali Eller

Reputation: 125

Touches on a subview outside the frame of its superview

Need help.

Create a menu outside the frame of superview. menu=[[MyView alloc]initWithFrame:CGRectMake(0, -100, 320, 100)];

When the menu is moved to the screen, superview moves too.

    -(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)
     {

     }];}

The menu has 5 buttons.

The problem is that they doesn't respond to touch events. I've read that it is necessary to replace:hitTest:withEvent:, but I do not understand how to do that.

Thanks!

Upvotes: 1

Views: 473

Answers (1)

Vitali Eller
Vitali Eller

Reputation: 125

I found a solution. Need to increase the window bounds. Replaced the line view.frame with view.bounds. The problem was that the touch events are not responds outside the window bounds.

Thanks all!

P.S. Sorry for my english!

Upvotes: 1

Related Questions