12

I just want to clear this up once and for all, is it ok to subclass a UIWebView? Will I ever have to be nervous about apple rejecting the app because of a UIWebView subclass?

The documentation states:

Subclassing Notes The UIWebView class should not be subclassed.

But at the same time Apple contradicts itself with this WWDC video:

https://developer.apple.com/videos/wwdc/2011/?id=511#rich-text-editing-in-safari-on-ios

In slide 41 they specifically talk about subclassing a UIWebView

Thanks in advance!

4 Answers4

8

While "Subclassing Notes" from UIWebView documentation explicitly discourage you from subclassing, your application will not be rejected because of subclassing UIWebView.

The real question you should ask is: "do I really need to subclass UIWebView or maybe adding methods via category (with or without associative storage) will suit my needs?". If category is not enough, go with subclassing.

matm
  • 7,059
  • 5
  • 36
  • 50
  • 1
    In my experience, subclassing UIWebView leads to broken accessibility unless you work around it. I know there is a work around as I've done it. Paradoxically, I don't actually know what the work around is. – William Jockusch Feb 24 '16 at 11:52
0

Sure You can subclass a UIWebView as any other class. But Apple documentations suggest us not to subclass a UIWebView. But It's doesnt mean that they are going to reject such apps in appstore review process. I give you 100% guarantee on this. There are several apps approved in the appstore in this category.

manujmv
  • 6,450
  • 1
  • 22
  • 35
0

You can sub class UIWebView... but it is made to use as it is. But you should be careful with customizations.

Subclassing is done mainly for reverting any existing properties of a class and if your need is to add new properties you can always use Categories.

Raon
  • 1,266
  • 3
  • 12
  • 25
0

While it's technically possible, and you might not even get rejected for it as some others mentioned, you should really ask yourself whether it's feasible for you to do so.

UIWebView is largely opague from a developer: You don't have any means to inspect or change what's going on in there. Maybe that's why Apple discourages you from subclassing UIWebView.

Matthias Wenz
  • 592
  • 4
  • 14