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?

+2


source to share


7 replies


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.

+4


source


I just rejected my application for using setScrollingEnabled, so BEWARE!



Their message is: "The non-public API that is included in your application is set to SetScrollingEnabled"

+2


source


If the method is not in the .h file, it is private. This is a pretty simple rule of thumb. The fact that you need to do some kind of runtime "shenanigans" to simply send the message has to be said.

+2


source


Yes, this is considered illegal. In fact, I got a "warning" that setSCrollingEnabled is part of a private structure. They approved the app, but said that I need to delete this call for the next update I send.

+1


source


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.

+1


source


This may be dubious, but not a reason for rejection if you have fallback behavior when / if a method cannot be found. The worst offenses have happened and gone.

0


source


Well, maybe they think you did it differently, like taking the content of an external UIWebView screen and displaying it in a simple UIIMage view, or having the HTML page content on the page limit its size and display it in a UIWebView.

0


source







All Articles