Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS UIScrollView in UIView
    text
    copied!<p>I have a little bit specific question. It might not matter for most people but I have had to deal with it and I had to solve the issue described below. I tried to find some information about it using Google and the Apple SDK documentation but did not succeed.</p> <p>I was a designing a screen where there were many images in horizontal scrolls. There three three same scrolls. Every scroll had title. I have implemented custom class derived from <code>UIView</code> and placed there <code>UIScrollView</code> for scroll and <code>UILabel</code> for title text:</p> <pre><code>@interface MyView : UIView { UIScrollView *iScrollView; UIView *iTitleView; } </code></pre> <p>I then put objects of this class on the view of a <code>UIViewController</code>:</p> <pre><code>@implementation MyViewController - (void) viewDidLoad { [super viewDidLoad]; ... iScrollViewTop = [[MyView alloc] init]; [self.view addSubview:iScrollViewTop]; ... } @end </code></pre> <p>When I filled the internal scroll view with images and ran my application it looked OK. But there was some strange behavior. First, scroll did not have bounces as if I had set</p> <pre><code>iScrollView.bounces = NO; </code></pre> <p>and second, when I swiped to scroll, after the scroll stopped, the scroll bar did not disappear within one second. It was strange for me, because when I usually create a UIScrollView and add it to the <code>UIViewController</code>'s view it has bounces and scroll bar disappears immediately when it stops. I tried to change <code>UIScrollView</code>'s properties, such as <code>directionalLockEnabled</code>, <code>pagingEnabled</code>, <code>canCancelContentTouches</code>, <code>delaysContentTouches</code>, <code>decelerationRate</code> and others. In fact, I have tried to change almost all properties of <code>UIScrollView</code> but I could not get the scroll bars to immediately disappear.</p> <p>If I try to add <code>UIScrollView</code> instead <code>MyView</code> to the <code>UIViewController.view</code>, it bounces and scroll bar disappears immediately after it stops. Also I get correct behavior if I subclass <code>MyView</code> from <code>UIScrollView</code> but in this case I cannot manage the title label because it scrolls together with other content.</p> <p>So here are my questions:</p> <ol> <li>Do you know why I am seeing this behavior?</li> <li>How can I get "usual" behavior for scroll encapsulated by <code>UIView</code>?</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload