Is this viewed as using private functions in the iPhone dev and thus illegal?
I am trying to disable scrolling for a UIWebView and the only way I have found is this:
#import <objc/runtime.h>
id scroller = [[Webview subviews] lastObject];
int count;
Method *method = class_copyMethodList([scroller class], &count);
int i;
for (i=0; i<count; i++) {
if (strcmp(method_getName(method[i]), "setScrollingEnabled:") == 0)
break;
}
IMP test = method_getImplementation(method[i]);
test(scroller, @selector(setScrollingEnabled:), NO);
Is this considered an illegal way to use the iPhone SDK? Could this reject the app store app?
source to share
it would be much easier to do this:
if ([scroller respondsToSelector: @selector(setScrollingEnabled:)]) [scroller setScrollingEnabled: NO]
This avoids any potential method calls they might scan your binary for (not sure how they check for "legitimacy"). It's still not 100% kosher, but definitely safer.
source to share
It works -
UIScrollView *scrollView = [[myWebView subviews] lastObject];
scrollView.scrollEnabled = FALSE;
This fixes the issue while keeping click links, any scrollViews embedded in scrollable ones, and only use the public APIs.
I found that javascript solutions did not allow WebViews to work correctly if it was embedded in UIScrollView
and the setting userInteractionEnabled
to make falsely flagged links in the web browser clickable.
source to share