A view that embeds web content in your app.


@interface UIWebView : UIView


Use the loadHTMLString:baseURL: method to begin loading local HTML files or the loadRequest: method to begin loading web content. Use the stopLoading method to stop loading, and the loading property to find out if a web view is in the process of loading.

If you allow the user to move back and forward through the webpage history, then you can use the goBack and goForward methods as actions for buttons. Use the canGoBack and canGoForward properties to disable the buttons when the user can’t move in a direction.

By default, a web view automatically converts telephone numbers that appear in web content to Phone links. When a Phone link is tapped, the Phone app launches and dials the number. To turn off this default behavior, set the dataDetectorTypes property with a UIDataDetectorTypes bitfield that does not contain the UIDataDetectorTypePhoneNumber flag.

You can also use the scalesPageToFit property to programmatically set the scale of web content the first time it is displayed in a web view. Thereafter, the user can change the scale using gestures.

Set the delegate property to an object conforming to the UIWebViewDelegate protocol if you want to track the loading of web content.

You can easily debug the HTML, CSS, and JavaScript contained inside a UIWebView with Web Inspector. Read Debugging Web Content on iOS to learn how to configure Web Inspector for iOS. Read the rest of Safari Web Content Guide to learn how to create web content that is optimized for Safari on iPhone and iPad.

For information about basic view behaviors, see View Programming Guide for iOS.

Supported File Formats

In addition to HTML content, UIWebView objects can be used to display other content types, such as Keynote, PDF, and Pages documents. For the best rendering of plain and rich text in your app, however, you should use UITextView instead.

State Preservation

In iOS 6 and later, if you assign a value to this view’s restorationIdentifier property, it attempts to preserve its URL history, the scaling and scrolling positions for each page, and information about which page is currently being viewed. During restoration, the view restores these values so that the web content appears just as it did before. For more information about how state preservation and restoration works, see App Programming Guide for iOS.

For more information about appearance and behavior configuration, see Web Views.

Subclassing Notes

The UIWebView class should not be subclassed.


Responding to Web View Changes


The receiver’s delegate.


The UIWebViewDelegate protocol defines methods that a delegate of a UIWebView object can optionally implement to intervene when web content is loaded.

Loading Content

- loadData:MIMEType:textEncodingName:baseURL:

Sets the main page contents, MIME type, content encoding, and base URL.

- loadHTMLString:baseURL:

Sets the main page content and base URL.

- loadRequest:

Connects to a given URL by initiating an asynchronous client request.


The URL request identifying the location of the content to load.


A Boolean value indicating whether the receiver is done loading content.

- stopLoading

Stops the loading of any web content managed by the receiver.

- reload

Reloads the current page.

Moving Back and Forward


A Boolean value indicating whether the receiver can move backward.


A Boolean value indicating whether the receiver can move forward.

- goBack

Loads the previous location in the back-forward list.

- goForward

Loads the next location in the back-forward list.

Setting Web Content Properties


A Boolean value that determines whether pressing on a link displays a preview of the destination for the link.


A Boolean value determining whether the webpage scales to fit the view and the user can change the scale.


The scroll view associated with the web view.


A Boolean value indicating whether the web view suppresses content rendering until it is fully loaded into memory.


A Boolean value indicating whether web content can programmatically display the keyboard.


The types of data converted to clickable URLs in the web view’s content.

Running JavaScript

- stringByEvaluatingJavaScriptFromString:

Returns the result of running a JavaScript script. Although this method is not deprecated, best practice is to use the evaluateJavaScript:completionHandler: method of the WKWebView class instead.

Managing Media Playback


A Boolean value that determines whether HTML5 videos play inline or use the native full-screen controller.


A Boolean value that determines whether HTML5 videos can play automatically or require the user to start playing them.


A Boolean value that determines whether Air Play is allowed from this view.


A Boolean value that determines whether Picture in Picture playback is allowed from this view.

Managing Pages


The size of the gap, in points, between pages.


The number of pages produced by the layout of the web view.


The size of each page, in points, in the direction that the pages flow.


The manner in which column- or page-breaking occurs.


The layout of content in the web view.

Deprecated Properties


A Boolean value indicating whether telephone number detection is on.



Constant indicating the user’s action.


The manner in which column- or page-breaking occurs.


The layout of content in the web view, which determines the direction that the pages flow.


Defines the types of information that can be detected in text-based content.


Inherits From

See Also

Content Views


A view that shows that a task is in progress.


An object that displays a single image or a sequence of animated images in your interface.


A view that uses a spinning-wheel or slot-machine metaphor to show one or more sets of values.


A view that depicts the progress of a task over time.