0

I have a container view which contains an UIScrollView and an UIView, that are at the same level with the same frame and bounds, meaning they are subviews of the container view.

But the UIView is on the top of the UIScrollView. So the problem is that the buttons or gestures on the UIView are responded to my touches, while the UIScrollView is not, either scrolling or zooming.

So how can I make the UIScrollView respond to scrolling and zooming and UIView respond to touches at the same time when these two views are on the same level of the same super view?

UPDATE:

What I'm trying to do is I want to have a player control panel view which contains play/pause button, progress button etc., and behind this panel view there is a player render view which is in charge of rendering the video frames.

And I want to make the render view be able to be zoomed and scrolled, while the control panel view stays still.

The sample code is like this:

@implementation MyVC: UIViewController <UIScrollViewDelegate>

- (void)viewDidLoad
{
   UIView *view = [UIView new];
   UIScrollView *scrollView = [UIScrollView new];
   [self.view addSubview:scrollView];
   [self.view addSubview:view];
   view.frame = scrollView.frame = self.view.frame;

   //zooming and scrolling settings code

   //now the problem is that scrollview does not respond to my zooming and scrolling
   //while the view does.
}

@end
bolizhou
  • 1,208
  • 1
  • 13
  • 31
  • 2
    The UIView must be a subview of the UIScrollView. – Xchord Aug 17 '17 at 06:30
  • 2
    Either you need to do as @Xchord worte. But if you want to keep the UIScrollview behind the UIView you are in for some messy UI structure. https://stackoverflow.com/questions/9209998/forwarding-uigesture-to-views-behind –  Aug 17 '17 at 06:33
  • Can't you place the buttons etc on `self.view`? In other words, please share what you're trying to accomplish; there might well be other ways. – meaning-matters Aug 17 '17 at 06:46
  • @meaning-matters if I placed the buttons on `self.view`, they would not be visible since there is an `uiscrollview` which is not transparent on its top as its subview. – bolizhou Aug 17 '17 at 07:05
  • do you tried this with uitableview ? instead of using scrollview and a view. – R. Mohan Aug 17 '17 at 07:05
  • @R.Mohan, what's your point, how would a table view help? I'm not listing something, I'm trying to scroll and zoom a video render view. – bolizhou Aug 17 '17 at 07:39
  • Just put the buttons above the scrollview and they will be visible. – meaning-matters Aug 17 '17 at 07:51
  • @meaning-matters, in that case, if I zoom and scroll it, the button will be zoomed or scrolled as well which is not good. – bolizhou Aug 17 '17 at 08:01
  • I thought you were only scrolling & zooming `scrollView`, but not the view controller's `self.view`. If you're scrolling & zooming **both `self.view` and `scrollView`**, then indeed buttons on `self.view` would also move & scale. – meaning-matters Aug 17 '17 at 08:06

1 Answers1

0

Maybe you can try this:

[view addGestureRecognizer:scrollView.panGestureRecognizer];

Or add any other UIGestureRecognizer in scrollView.gestureRecognizers to view. But it possibly will cause some issues when zooming. I did not check it. Maybe adding your buttons play/pause to the container view on the level same as scrollView is a better way.

liftlift
  • 59
  • 4