Topics

#18: SFSafariViewController πŸ‘’πŸ„

Topics

SFSafariViewController is another new addition in iOS 9, and it’s a great one.

Get ready to throw out all that custom in-app browser or third-party library code you’ve been using.

Unlike other solutions, SFSafariViewController embeds all of the power of Safari on iOS (including Autofill, shared cookies, etc.) directly into your app.

Replacing your existing solutions should be trivial for most people, here’s how:

import SafariServices

class BookmarksViewController : UITableViewController {

  func didSelectBookmark(bookmark: Bookmark) {
    let vc = SFSafariViewController(
      URL: bookmark.URL,
      entersReaderIfAvailable: false
    )

    presentViewController(vc, animated: true, completion: nil)
  }

}

SFSafariViewController Pro Tips

  • set a delegate to configure custom activity items in the share sheet
  • use the entersReaderIfAvailable property to start the user in reader view