Xavier
Xavier

Reputation: 9059

How do I forward touch events to a view behind a uicollectionview?

I have a uicollectionviewcontroller which I use to create a small toolbar at the bottom of the screen. I add the view of the uicollectionviewcontroller to another viewcontroller's view. My problem is that it won't forward touch events to a view underneath it. I did move it to the bottom and that worked for a while but now I need to use 2 uicollection views.

How am I supposed to forward touch events to views beneath a uicollectionviewcontroller's view?

Upvotes: 1

Views: 681

Answers (2)

abhishekkharwar
abhishekkharwar

Reputation: 3529

As i think you can add your toolbar as footer of UICollectionView and it will work

have a look into this link How to Add Header and Footer View in UICollectionView

Upvotes: 0

Alua K
Alua K

Reputation: 398

In case the question is still relevant, the following can be used to achieve touch forwarding.

  1. Subclass UICollectionView
  2. Overwrite - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
        [super touchesEnded:touches withEvent:event];
        [self.yourCustomDelegate forwardTouches:touches withEvent:(UIEvent *)event];
    }
    

    That is how UICollectionView can keep its ability to respond to user interaction, and the same time forward received touches.

Upvotes: 2

Related Questions