0

In my iOS app, I would like to set the delegate of my PageViewController's main UIScrollView.

There is tons of answer that say : "Ok man, juste iterate over subview and you will find the scrollview".

Ok, it works, but does it pass the Apple Validation Step ? Is it not a call to private API ? Does someone successfully published an app with this trick ?

Thanks everyone,

CZ54
  • 5,488
  • 1
  • 24
  • 39
  • 1
    Apple's validation just keyword searches for blacklisted selectors and class names. Probing subviews is fine but you risk Apple changing the view hierarchy on subsequent OS releases. – Brian Nickel Jan 06 '15 at 17:09
  • So for you, it will pass the validation ? – CZ54 Jan 06 '15 at 17:13
  • it will pass validation as long as you don't call an undocumented APIs or your program behaves like you say it does without any hidden functionality. – rakeshbs Jan 06 '15 at 17:16

1 Answers1

1

In short, no, this is not going to trip Apple's validation step. See this answer for a list of ways Apple detects private API usage. They're mostly looking for if you reference a private class or selector. For instance UIKeyboardImpl or _setViewDelegate:.

I personally have something very similar in the app store. I needed to get the UITextField in a UISearchBar so I have the following code:

UIView<UITextInput> *UISearchBarTextInput(UISearchBar *searchBar) {
    for (id view in searchBar.subviews) {

        // Could be in the top level. (iOS6)
        if ([view conformsToProtocol:@protocol(UITextInput)]) {
            return view;
        }

        // Or the next level. (iOS7)
        for (id subview in [view subviews]) {
            if ([subview conformsToProtocol:@protocol(UITextInput)]) {
                return subview;
            }
        }
    }

    return nil;
}

The big problem you are likely to run into is that you are dealing with a private view hierarchy and Apple makes no guarantees that this will stay constant between iOS releases. In the code above I have to support two different iOS versions. If they decided to make a change in iOS9 I would have to make modify my code. It's a good practice in this case to assume that your lookup may fail (you won't be able to find the scroll view or a new scroll view may be added) and make your code resilient to that case.

Also, you have to consider that a human will use your app as part of the app store review. If you change things too much from the expected behavior it can be rejected on that alone.

Community
  • 1
  • 1
Brian Nickel
  • 26,890
  • 5
  • 80
  • 110