---
title: UIWebView
framework: uikit
role: symbol
role_heading: Class
path: uikit/uiwebview
---

# UIWebView

A view that embeds web content in your app.

## Declaration

```swift
@MainActor class UIWebView
```

## Overview

Overview note: In apps that run in iOS 8 and later, use the WKWebView class instead of using UIWebView. Additionally, consider setting the WKPreferences property javaScriptEnabled to 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 and NSCameraUsageDescription. 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 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() 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 doesn’t contain the phoneNumber flag. You can also use the 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 property to an object conforming to the UIWebViewDelegate protocol if you want to track the loading of web content. important: You shouldn’t embed UIWebView or UITableView objects in 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 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’s 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. Subclassing notes The UIWebView class shouldn’t be subclassed.

## Topics

### Essentials

- [Replacing UIWebView in your app](webkit/replacing-uiwebview-in-your-app.md)

### Responding to web view changes

- [delegate](uikit/uiwebview/delegate.md)
- [UIWebViewDelegate](uikit/uiwebviewdelegate.md)

### Loading content

- [load(_:mimeType:textEncodingName:baseURL:)](uikit/uiwebview/load(_:mimetype:textencodingname:baseurl:).md)
- [loadHTMLString(_:baseURL:)](uikit/uiwebview/loadhtmlstring(_:baseurl:).md)
- [loadRequest(_:)](uikit/uiwebview/loadrequest(_:).md)
- [request](uikit/uiwebview/request.md)
- [isLoading](uikit/uiwebview/isloading.md)
- [stopLoading()](uikit/uiwebview/stoploading().md)
- [reload()](uikit/uiwebview/reload().md)

### Moving back and forward

- [canGoBack](uikit/uiwebview/cangoback.md)
- [canGoForward](uikit/uiwebview/cangoforward.md)
- [goBack()](uikit/uiwebview/goback().md)
- [goForward()](uikit/uiwebview/goforward().md)

### Setting web content properties

- [allowsLinkPreview](uikit/uiwebview/allowslinkpreview.md)
- [scalesPageToFit](uikit/uiwebview/scalespagetofit.md)
- [scrollView](uikit/uiwebview/scrollview.md)
- [suppressesIncrementalRendering](uikit/uiwebview/suppressesincrementalrendering.md)
- [keyboardDisplayRequiresUserAction](uikit/uiwebview/keyboarddisplayrequiresuseraction.md)
- [dataDetectorTypes](uikit/uiwebview/datadetectortypes.md)

### Running JavaScript

- [stringByEvaluatingJavaScript(from:)](uikit/uiwebview/stringbyevaluatingjavascript(from:).md)

### Managing media playback

- [allowsInlineMediaPlayback](uikit/uiwebview/allowsinlinemediaplayback.md)
- [mediaPlaybackRequiresUserAction](uikit/uiwebview/mediaplaybackrequiresuseraction.md)
- [mediaPlaybackAllowsAirPlay](uikit/uiwebview/mediaplaybackallowsairplay.md)
- [allowsPictureInPictureMediaPlayback](uikit/uiwebview/allowspictureinpicturemediaplayback.md)

### Managing pages

- [gapBetweenPages](uikit/uiwebview/gapbetweenpages.md)
- [pageCount](uikit/uiwebview/pagecount.md)
- [pageLength](uikit/uiwebview/pagelength.md)
- [paginationBreakingMode](uikit/uiwebview/paginationbreakingmode-swift.property.md)
- [paginationMode](uikit/uiwebview/paginationmode-swift.property.md)

### Constants

- [UIWebView.NavigationType](uikit/uiwebview/navigationtype.md)
- [UIWebView.PaginationBreakingMode](uikit/uiwebview/paginationbreakingmode-swift.enum.md)
- [UIWebView.PaginationMode](uikit/uiwebview/paginationmode-swift.enum.md)
- [UIDataDetectorTypes](uikit/uidatadetectortypes.md)

## Relationships

### Inherits From

- [UIView](uikit/uiview.md)

### Conforms To

- [CALayerDelegate](quartzcore/calayerdelegate.md)
- [CLBodyIdentifiable](corelocation/clbodyidentifiable.md)
- [CMBodyIdentifiable](coremotion/cmbodyidentifiable.md)
- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [UIAccessibilityIdentification](uikit/uiaccessibilityidentification.md)
- [UIActivityItemsConfigurationProviding](uikit/uiactivityitemsconfigurationproviding.md)
- [UIAppearance](uikit/uiappearance.md)
- [UIAppearanceContainer](uikit/uiappearancecontainer.md)
- [UICoordinateSpace](uikit/uicoordinatespace.md)
- [UIDynamicItem](uikit/uidynamicitem.md)
- [UIFocusEnvironment](uikit/uifocusenvironment.md)
- [UIFocusItem](uikit/uifocusitem.md)
- [UIFocusItemContainer](uikit/uifocusitemcontainer.md)
- [UILargeContentViewerItem](uikit/uilargecontentvieweritem.md)
- [UIPasteConfigurationSupporting](uikit/uipasteconfigurationsupporting.md)
- [UIPopoverPresentationControllerSourceItem](uikit/uipopoverpresentationcontrollersourceitem.md)
- [UIResponderStandardEditActions](uikit/uiresponderstandardeditactions.md)
- [UIScrollViewDelegate](uikit/uiscrollviewdelegate.md)
- [UITraitChangeObservable](uikit/uitraitchangeobservable-67e94.md)
- [UITraitEnvironment](uikit/uitraitenvironment.md)
- [UIUserActivityRestoring](uikit/uiuseractivityrestoring.md)

## See Also

### Deprecated classes

- [UIActionSheet](uikit/uiactionsheet.md)
- [UIAlertView](uikit/uialertview.md)
- [UIDocumentMenuViewController](uikit/uidocumentmenuviewcontroller.md)
- [UILocalNotification](uikit/uilocalnotification.md)
- [UIMenuController](uikit/uimenucontroller.md)
- [UIMenuItem](uikit/uimenuitem.md)
- [UIMutableUserNotificationAction](uikit/uimutableusernotificationaction.md)
- [UIMutableUserNotificationCategory](uikit/uimutableusernotificationcategory.md)
- [UIPopoverController](uikit/uipopovercontroller.md)
- [UIPreviewAction](uikit/uipreviewaction.md)
- [UIPreviewActionGroup](uikit/uipreviewactiongroup.md)
- [UISearchDisplayController](uikit/uisearchdisplaycontroller.md)
- [UIStoryboardPopoverSegue](uikit/uistoryboardpopoversegue.md)
- [UIUserNotificationAction](uikit/uiusernotificationaction.md)
- [UIUserNotificationCategory](uikit/uiusernotificationcategory.md)
