<!--
{
  "availability" : [
    "iOS: 2.0.0 - 12.0.0",
    "iPadOS: 2.0.0 - 12.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIWebView",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIWebView"
  },
  "title" : "UIWebView"
}
-->

# UIWebView

A view that embeds web content in your app.

```
@MainActor class UIWebView
```

## Overview> Note:
> In apps that run in iOS 8 and later, use the <doc://com.apple.documentation/documentation/WebKit/WKWebView> class instead of using ``doc://com.apple.uikit/documentation/UIKit/UIWebView``. Additionally, consider setting the <doc://com.apple.documentation/documentation/WebKit/WKPreferences> property <doc://com.apple.documentation/documentation/WebKit/WKPreferences/javaScriptEnabled> to <doc://com.apple.documentation/documentation/Swift/false> if you render files that aren’t supposed to run JavaScript.

> Important:
> An iOS app linked on or after iOS 10.0 must include in its `Info.plist` file the usage description keys for the types of data it needs to access or it will crash. To access a user’s photo data specifically, it must include [NSPhotoLibraryUsageDescription](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW17) and [NSCameraUsageDescription](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW24).

Use the [`loadHTMLString(_:baseURL:)`](/documentation/UIKit/UIWebView/loadHTMLString(_:baseURL:)) method to begin loading local HTML files or the [`loadRequest(_:)`](/documentation/UIKit/UIWebView/loadRequest(_:)) method to begin loading web content. Use the [`stopLoading()`](/documentation/UIKit/UIWebView/stopLoading()) method to stop loading, and the [`isLoading`](/documentation/UIKit/UIWebView/isLoading) 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()`](/documentation/UIKit/UIWebView/goBack()) and [`goForward()`](/documentation/UIKit/UIWebView/goForward()) methods as actions for buttons. Use the [`canGoBack`](/documentation/UIKit/UIWebView/canGoBack) and [`canGoForward`](/documentation/UIKit/UIWebView/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`](/documentation/UIKit/UIWebView/dataDetectorTypes) property with a [`UIDataDetectorTypes`](/documentation/UIKit/UIDataDetectorTypes) bitfield that doesn’t contain the [`phoneNumber`](/documentation/UIKit/UIDataDetectorTypes/phoneNumber) flag.

You can also use the [`scalesPageToFit`](/documentation/UIKit/UIWebView/scalesPageToFit) property to programmatically set the scale of web content the first time it’s displayed in a web view. Thereafter, the user can change the scale using gestures.

Set the [`delegate`](/documentation/UIKit/UIWebView/delegate) property to an object conforming to the [`UIWebViewDelegate`](/documentation/UIKit/UIWebViewDelegate) protocol if you want to track the loading of web content.

> Important:
> You shouldn’t embed ``doc://com.apple.uikit/documentation/UIKit/UIWebView`` or ``doc://com.apple.uikit/documentation/UIKit/UITableView`` objects in ``doc://com.apple.uikit/documentation/UIKit/UIScrollView`` objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

You can debug the HTML, CSS, and JavaScript contained inside a [`UIWebView`](/documentation/UIKit/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](https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/Introduction/Introduction.html#//apple_ref/doc/uid/TP40002051) to learn how to create web content that’s optimized for Safari on iPhone and iPad.

For information about basic view behaviors, see [View Programming Guide for iOS](https://developer.apple.com/library/archive/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009503).

### Supported file formats

In addition to HTML content, [`UIWebView`](/documentation/UIKit/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`](/documentation/UIKit/UITextView) instead.

### State preservation

In iOS 6 and later, if you assign a value to this view’s [`restorationIdentifier`](/documentation/UIKit/UIViewController/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](https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007072).

### Subclassing notes

The [`UIWebView`](/documentation/UIKit/UIWebView) class shouldn’t be subclassed.

## Topics

### Essentials

  <doc://com.apple.documentation/documentation/WebKit/replacing-uiwebview-in-your-app>

### Responding to web view changes

[`delegate`](/documentation/UIKit/UIWebView/delegate)

The receiver’s delegate.

[`UIWebViewDelegate`](/documentation/UIKit/UIWebViewDelegate)

The `UIWebViewDelegate` protocol defines methods that a delegate of a [`UIWebView`](/documentation/UIKit/UIWebView) object can optionally implement to intervene when web content is loaded.

### Loading content

[`load(_:mimeType:textEncodingName:baseURL:)`](/documentation/UIKit/UIWebView/load(_:mimeType:textEncodingName:baseURL:))

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

[`loadHTMLString(_:baseURL:)`](/documentation/UIKit/UIWebView/loadHTMLString(_:baseURL:))

Sets the main page content and base URL.

[`loadRequest(_:)`](/documentation/UIKit/UIWebView/loadRequest(_:))

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

[`request`](/documentation/UIKit/UIWebView/request)

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

[`isLoading`](/documentation/UIKit/UIWebView/isLoading)

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

[`stopLoading()`](/documentation/UIKit/UIWebView/stopLoading())

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

[`reload()`](/documentation/UIKit/UIWebView/reload())

Reloads the current page.

### Moving back and forward

[`canGoBack`](/documentation/UIKit/UIWebView/canGoBack)

A Boolean value indicating whether the receiver can move backward.

[`canGoForward`](/documentation/UIKit/UIWebView/canGoForward)

A Boolean value indicating whether the receiver can move forward.

[`goBack()`](/documentation/UIKit/UIWebView/goBack())

Loads the previous location in the back-forward list.

[`goForward()`](/documentation/UIKit/UIWebView/goForward())

Loads the next location in the back-forward list.

### Setting web content properties

[`allowsLinkPreview`](/documentation/UIKit/UIWebView/allowsLinkPreview)

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

[`scalesPageToFit`](/documentation/UIKit/UIWebView/scalesPageToFit)

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

[`scrollView`](/documentation/UIKit/UIWebView/scrollView)

The scroll view associated with the web view.

[`suppressesIncrementalRendering`](/documentation/UIKit/UIWebView/suppressesIncrementalRendering)

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

[`keyboardDisplayRequiresUserAction`](/documentation/UIKit/UIWebView/keyboardDisplayRequiresUserAction)

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

[`dataDetectorTypes`](/documentation/UIKit/UIWebView/dataDetectorTypes)

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

### Running JavaScript

[`stringByEvaluatingJavaScript(from:)`](/documentation/UIKit/UIWebView/stringByEvaluatingJavaScript(from:))

Returns the result of running a JavaScript script.

### Managing media playback

[`allowsInlineMediaPlayback`](/documentation/UIKit/UIWebView/allowsInlineMediaPlayback)

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

[`mediaPlaybackRequiresUserAction`](/documentation/UIKit/UIWebView/mediaPlaybackRequiresUserAction)

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

[`mediaPlaybackAllowsAirPlay`](/documentation/UIKit/UIWebView/mediaPlaybackAllowsAirPlay)

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

[`allowsPictureInPictureMediaPlayback`](/documentation/UIKit/UIWebView/allowsPictureInPictureMediaPlayback)

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

### Managing pages

[`gapBetweenPages`](/documentation/UIKit/UIWebView/gapBetweenPages)

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

[`pageCount`](/documentation/UIKit/UIWebView/pageCount)

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

[`pageLength`](/documentation/UIKit/UIWebView/pageLength)

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

[`paginationBreakingMode`](/documentation/UIKit/UIWebView/paginationBreakingMode-swift.property)

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

[`paginationMode`](/documentation/UIKit/UIWebView/paginationMode-swift.property)

The layout of content in the web view.

### Constants

[`UIWebView.NavigationType`](/documentation/UIKit/UIWebView/NavigationType)

Constant indicating the user’s action.

[`UIWebView.PaginationBreakingMode`](/documentation/UIKit/UIWebView/PaginationBreakingMode-swift.enum)

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

[`UIWebView.PaginationMode`](/documentation/UIKit/UIWebView/PaginationMode-swift.enum)

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

[`UIDataDetectorTypes`](/documentation/UIKit/UIDataDetectorTypes)

Constants that define the types of information to detect in text-based content.

### Deprecated

[`detectsPhoneNumbers`](/documentation/UIKit/UIWebView/detectsPhoneNumbers)

A Boolean value indicating whether telephone number detection is on.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)