What is the difference in terms of UIViewController and SFSafariViewController navigation?

1

I would like to know the advantages and disadvantages of webview controllers SFSafariViewController and UIViewController , for the questions below:
 - performance
 - compatibility
 - usability

    
asked by anonymous 23.04.2018 / 20:42

1 answer

1

A recurring situation in mobile development is showing the content of a web page. Basically there were two solutions to this problem. The first was to open the link in the Safari app, which is fairly simple to implement, but it generates a poor user experience. The other alternative was to develop a 'mini-browser', allowing the user to view web content without leaving the app, but making the development more complex and the user experience is not ideal either.

Then in iOS 9 the SFSafariViewController was introduced. It basically serves to open a browser within the app and provides a superior browsing experience, just like Safari. In addition it requires almost no development effort. However, the use of the SFSafariViewController is quite restricted. This component is a subclass of UIViewController, which receives a URL at startup. An example application is to open a web link when the user clicks on it or to open a particular website.

UIViewController can be seen as an entity that controls the layout, content, and handling of UI events. Usually for each App screen there is a UIViewController . In general, the interface components are defined in a separate file (.xib, .storyboard) and in the ViewController we modify the contents of the interface, we have events like clicks and change of state (eg: viewDidLoad , viewDidDisappear ), among many other assignments.

As the purposes of UIViewController and SFSafariViewController are distinct, it is difficult to compare. SFSafariViewController does not offer much customization and looks like a browser. This is indicated when the app simply needs to open a web page. If your application needs more flexibility on how web content is displayed or for other more specific applications, the solution is to use WKWebView . This component is added in the Views hierarchy of the ViewController and then you need to implement the code to load the desired URL and handle events.

    
23.04.2018 / 23:46