-
Notifications
You must be signed in to change notification settings - Fork 772
Provide a way to perform java script code in a readers page from external code #155
Provide a way to perform java script code in a readers page from external code #155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you think is better to subclass the UIWebView
instead of a extension, as it is not public to override?
@@ -157,7 +157,7 @@ public class FolioReaderPage: UICollectionViewCell, UIWebViewDelegate, UIGesture | |||
} | |||
|
|||
UIView.animateWithDuration(0.2, animations: {webView.alpha = 1}) { finished in | |||
webView.isColors = false | |||
(webView as? FolioReaderWebView)?.isColors = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets reduce the (webView as? FolioReaderWebView)
cast, we can just cast with guard on beginning of the function.
guard let webView = webView as? FolioReaderWebView else { return }
Then just use webView
as previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this seems to be the better approach, I'll adjust it.
webView.createMenu(options: true) | ||
webView.setMenuVisible(true, andRect: rect) | ||
(webView as? FolioReaderWebView)?.createMenu(options: true) | ||
(webView as? FolioReaderWebView)?.setMenuVisible(true, andRect: rect) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for casting here and so on...
I think it's better to use a subclass instead of an extension because:
|
This PR:
UIWebView
extension to the subclassFolioReaderWebView
FolioReaderPage