Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is subclassing UIWebView frowned upon? [closed]

I've heard varying things about whether or not creating a Subclass of UIWebView is allowable. Can someone link me to any documentation that clarifies this one way or another?

like image 549
BadPirate Avatar asked Dec 04 '22 23:12

BadPirate


1 Answers

There are mixed messages coming from Apple on this.

The docs do say not to subclass as BoltClock noted. However, one of the presentations from WWDC 2011, Rich Text Editing in Safari on iOS, suggests subclassing. It appears to be the only way to add custom UIMenuItems.

From the slides:

// For your UIWebView subclass:
- (void)bold:(id)sender {
    [self stringByEvaluatingJavaScript:@”document.execCommand(‘Bold’)];
 }
 - (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
    if (action == @selector(bold:))
    return YES;
    return [super canPerformAction:action withSender:sender];
}

I need functionality other than Copy and Paste in my app so I'll be subclassing.

like image 127
Justin Milo Avatar answered Dec 14 '22 06:12

Justin Milo