Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For a similar problem, I made UIScrollView subclass like the following: PoliteScrollView passes touch messages to it's subviews when it determines that they are being dragged.</p> <pre><code>@interface PoliteScrollView : UIScrollView // number of pixels perpendicular to the scroll views orientation to make a drag start counting as a subview drag // defaults to 1/10 of the scroll view's width or height, whichever is smaller @property(nonatomic,assign) CGFloat subviewDraggingThreshold; // yes when a subview is being dragged @property(nonatomic,assign) BOOL isDraggingSubview; // the subview being dragged @property(nonatomic,strong) UIView *draggingSubview; @end @protocol PoliteScrollViewDelegate &lt;NSObject&gt; @optional - (void)scrollView:(PoliteScrollView *)scrollView subviewTouchesBegan:(NSSet *)touches; - (void)scrollView:(PoliteScrollView *)scrollView subviewTouchesMoved:(NSSet *)touches; - (void)scrollView:(PoliteScrollView *)scrollView subviewTouchesEnded:(NSSet *)touches; @end </code></pre> <p>The key design idea is that dragging in a scroll view is ambiguous. Is the user scrolling or dragging a subview? PoliteScroll view handles this by providing two things: (1) a notion of orientation (horizontal if it's longer than it is wide, vertical otherwise), and (2) a threshold distance for what constitutes a drag in the direction perpendicular to it's orientation. (defaults to 1/10 the width or height).</p> <p>I pasted this and several other files are in a <a href="http://pastebin.com/LdYjVU7p" rel="nofollow">paste bin</a>, containing the following:</p> <ul> <li>PoliteScrollView .h and .m</li> <li>DraggableImageView.h and .m - that changes it's position when it gets touch messages.</li> <li>ViewController.m - that demonstrates thetwo in combination.</li> </ul> <p>To combine these in a project, paste the paste bin into files appropriately named, add a storyboard with a PoliteScrollView (be sure to set it's delegate), add in some images (the ViewController tries to add puppy0.jpeg to puppy4.jpeg.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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