Yet Another Browser View Controller.
We've all written these things a million times. Here's another one.
When to use YABrowserViewController
You're tired of, or want a head start on, rewriting a little skin over a web view so that people don't get punted out to Safari just to open a website. And you want
WKWebView's power while mitigating its deficiencies.
When not to use YABrowserViewController
You want third-party code to permanently mess with your navigation bars. You love undocumented Key-Value Observing usage. You'd like a bunch of other dependencies to be pulled in. You need
NSURLProtocol, access to folders that aren't
tmp, state-preserved URL history, or something else that
WKWebView doesn't care for.
YABrowserViewController supports iOS 8.0+.
You have options:
YABrowserViewController.xcodeprojinto your project, add
YABrowserViewControlleras a Target Dependency, then add
YABrowserViewController.frameworkto your Embedded Binaries, then
import YABrowserViewControlleras necessary. (This is how the included sample app is configured, if you need inspiration.)
YABrowserViewController.minto your project, along with the
- Either of the above options, but first add this repository as a submodule.
- Using CocoaPods, add to your Podfile:
- Using Carthage, add to your Cartfile:
let browser = YABrowserViewController() browser.URLString = "https://github.com/nolanw/YABrowserViewController" browser.presentFromViewController(self, animated: true, completion: nil)
Customization isn't YABrowserViewController's strong suit, in that it doesn't really do very much. There aren't any knobs to dial. Instead, you can just set the view controller and navigation controller properties yourself to do whatever you like. Or copy the files over and edit them to suit your needs.
For example, there's a little convenience method there,
-presentFromViewController:animated:completion:, for modal presentation. Not enough? Toss a category on
YABrowserViewController and set up a
UINavigationController however you please!
If you'd like to poke around, see the SampleBrowser app. It has UIKit state preservation and restoration enabled, so you can test that out.
No shortage of these.
YABrowserViewController is by Nolan Waite.