What is the difference in terms of Uiviewcontroller and Sfsafariviewcontroller navigation?

Asked

Viewed 67 times

1

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 quite simple to implement, but generates a bad 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, in addition to the user experience also not ideal.

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

Uiviewcontroller can be viewed as an entity that controls the layout, content and handling of user interface events. Usually for each screen of the App there is a Uiviewcontroller. In general, interface components are defined in a separate file (.xib, . storyboard) and in Viewcontroller we modified the content of the interface, bringing events such as clicks and change of state (ex: viewDidLoad, viewDidDisappear), among many other duties.

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. It is indicated when the app simply needs to open a web page. If your application requires more flexibility about how web content is shown or for other, more specific applications, the solution is to use Wkwebview. This component is added to the Viewcontroller view hierarchy and then you need to implement the code to load the desired URL and handle events.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.