1

I have several sub views added to a UIScrollView in the main view controller. Each sub view's view controller has its own tap recognizer. The problem is, only tapping in the starting area on the screen is recognised. After scrolling the view and tapping beyond the starting area, the tapping handler will no longer be called.

This SO post UIButton in non-visible area of UIScrollView seems to be relevant but its solution description wasn't really clear to me...

A simple report project could be found at: dropbox link

Thanks.

Community
  • 1
  • 1
Jack X.
  • 85
  • 2
  • 10
  • what is issue , you have added tap gesture for both part ? – Prashant Tukadiya Jun 20 '16 at 12:38
  • The scroll view's content size is 2000*800, which is larger than the screen size. When the app is initially launched and user tapes, the tap handler is recognised. If you scroll the screen to the right and tap on the right-most area, the tap handler will no longer be triggered. – Jack X. Jun 20 '16 at 13:40
  • @MikeAlter by both part do you mean the visible and invisible parts of the scroll view? If so, how do I add tap gesture for the part beyond the visible area initially? – Jack X. Jun 20 '16 at 14:24

2 Answers2

0

Please check your contentview size or setbackground color for scrollview and contentview. Contenview size is not increasing i think.

Bhadresh Mulsaniya
  • 2,610
  • 1
  • 12
  • 25
0

I have downloaded your project and see that the

SSubViewController *pvc = [SSubViewController controllerWithSubViewID:0]; 

pvc frame is out of bound

SSubViewController *pvc = [SSubViewController controllerWithSubViewID:0];
[self.scrollView addSubview:pvc.view];
[self addChildViewController:pvc];
[pvc.view setBackgroundColor:[UIColor grayColor]];
[pvc.view setFrame:CGRectMake(0, 0, 400, 200)];

[pvc didMoveToParentViewController:self];

SSubViewController *pvc1 = [SSubViewController controllerWithSubViewID:1];
[self.scrollView addSubview:pvc1.view];
[pvc1.view setBackgroundColor:[UIColor yellowColor]];
[self addChildViewController:pvc1];
[pvc1 didMoveToParentViewController:self];
[pvc1.view setFrame:CGRectMake(0, 400, 400, 200)];

Now see the Colours

enter image description here

As you can see Gray color, and Yellow color frame

Prashant Tukadiya
  • 15,838
  • 4
  • 62
  • 98