简体   繁体   中英

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!

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!

PS Sorry for my english!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM