The embedded UIScrollView will not bounce and does not detect slow swipe gestures when the bounce parameter is set to NO

Sorry for the long and understandable title, but UIScrollView has raised so many questions that it’s hard for me to reach those that can help in different situations.

I have nested scrollviews in my iPad app. So far so good, everything has its ups and downs, but its pretty sleek and responsive. My outter scroll view is an uploaded page containing full-screen or larger scrolling views of content. Outroll scrollview is horizontal and internal. Like the photo gallery. I found that when I scale and scroll the inner scroll, there is a noticeable delay in detecting slow and long swipe gestures ONLY when the scroll is scanned down to the bottom of the content and the bounce is off.

Another thing is that the internal scrollview bouncing property is YES / NO pseudo-randomly. So this is the code in the constructor that sets the internal scrolls that act up:

if (UIInterfaceOrientationIsPortrait(forOrientation)) { self.minimumZoomScale = 1.0; self.maximumZoomScale = 1.0; self.bounces = NO; self.alwaysBounceVertical = NO; self.scrollEnabled = NO; }else if (UIInterfaceOrientationIsLandscape(forOrientation)){ self.minimumZoomScale = 1.333333f; self.maximumZoomScale = 1.333333f; self.bounces = YES; self.alwaysBounceVertical = YES; self.scrollEnabled = YES; } self.scrollsToTop = NO; self.showsVerticalScrollIndicator = YES; self.showsHorizontalScrollIndicator = NO; self.directionalLockEnabled = YES; self.delegate = self; self.pagingEnabled = NO; self.canCancelContentTouches = NO; self.delaysContentTouches = YES; 

When the iPad is rotated, the bounce will come and be suitable for viewing the scroll, and will also have a rebound.

This is mistake? Or is it just me that I ruined it?

in advance for your time and interest!

UPDATE: I have nested two scrollviews, which are actually subclasses of UIScrollView. I do this because I need to override hitTest and other methods. I also tried the Better solution described here http://openradar.appspot.com/8045239 and did not get good results.

+4
source share
2 answers

I answer my question.

Open the solution to the problem with the radar, which was published on the question, it is not very clean in order to isolate, to stop changing uiscrollview and cancel bounces.

In principle, EVERYTHING that can change the view frame during layoutSubViews should only be done by ONCE, double checking that if the size is equal to the change encoded in layoutSubviews, then this does not work more than once.

 -(void)layoutSubviews { ///... if (!self.bounces) { self.bounces = YES; } if(!self.scrollEnabled){ self.scrollEnabled = YES; } if (!CGSizeEqualToSize(rect.size, self.contentSize)) { self.contentSize = rect.size; } if (self.zoomScale < MAXIMUM_ZOOM_SCALE ) { [self zoomToRect:ZOOM_RECT_MAKE animated:NO];// otherwise this line of code won't do anything at all } } 
+3
source

Scrollviews attachments will always lead to touch response issues. I assume that the internal is basic - do they interact more with one user? In general, you will probably have to write some of your own touch respondents (at least it was my experience, both in code and around SO). Make vertical scrolling more forgiving, but just discover a narrow range of paws and drags (almost horizontal lines) for the outside. Thus, most of the touch inputs will be sent to the internal view.

As for the rebound, delete one of the places where you set the property, and see what happens.

What method is this? Hope this code is in a subclass of UIView ...?

0
source

Source: https://habr.com/ru/post/1342707/


All Articles