While Titanium offers the power of using native UI components, sometimes it is necessary to use web content in our apps. For this reason, Titanium has the
Ti.UI.WebView component that gives you access to the platform's underlying native webview. With this component you get the full range of HTML/CSS/JS capabilities that the platform has to offer.
While it's highly encouraged to use native UI components whenever possible, there are some situations that are best suited for
- Rendering existing HTML/CSS
- Animation and interaction via the HTML5 <canvas> tag
- Integrating web-based tools
But be cautious when using
WebViews. They are the heaviest of native UI components. They take time to render and can effect the performance of your apps if used too often. This will be discussed in more detail in the WebView Use Cases section of this chapter.
Sections in this chapter
In this section, you'll learn how to use the
Ti.UI.WebView component to display and interact with web content in your apps. You'll see how to use both static and dynamic local web content, as well as existing webpages, RSS feeds, and other remote web content. You'll also find some resources for optimizing web content to work well with
WebViews (and mobile browsers).
WebViews and native Titanium code. This gives you the ability to have web content interact with the native Titanium environment and vice versa.
Finally, you'll explore some common use cases of the
Ti.UI.WebView in Titanium apps. You will also further explore why caution must be taken to not overuse these components, particularly when the same result could be achieved with native components.