Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Awesome help Sam! I used that to create a simple category that swizzles the method (because I was doing this in a UITableViewController and thus would have had to do some really messy stuff to subclass the scroll view).</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface UIScrollView (withControls) + (void) swizzle; @end </code></pre> <p>And the main code:</p> <pre><code>#import &lt;/usr/include/objc/objc-class.h&gt; #import "UIScrollView+withControls.h" #define kUIViewBackgroundImageTag 6183746 static BOOL swizzled = NO; @implementation UIScrollView (withControls) + (void)swizzleSelector:(SEL)orig ofClass:(Class)c withSelector:(SEL)new; { Method origMethod = class_getInstanceMethod(c, orig); Method newMethod = class_getInstanceMethod(c, new); if (class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) { class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); } else { method_exchangeImplementations(origMethod, newMethod); } } + (void) swizzle { @synchronized(self) { if (!swizzled) { [UIScrollView swizzleSelector:@selector(hitTest:withEvent:) ofClass:[UIScrollView class] withSelector:@selector(swizzledHitTest:withEvent:)]; swizzled = YES; } } } - (UIView*)swizzledHitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView* result = [self swizzledHitTest:point withEvent:event]; // actually calling the original hitTest method if ([result.superview isKindOfClass:[UIPickerView class]]) { self.canCancelContentTouches = NO; self.delaysContentTouches = NO; } else { self.canCancelContentTouches = YES; // (or restore bool from prev value if needed) self.delaysContentTouches = YES; // (same as above) } return result; } @end </code></pre> <p>Then, in my viewDidLoad method, I just called </p> <pre><code>[UIScrollView swizzle]; </code></pre>
    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. VO
      singulars
      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