Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To capture JavaScript changes in a legacy UIWebView, evaluate the script, wait until the page has reached the visual state you intend to capture, then draw the web view’s visible hierarchy into a graphics context with drawViewHierarchyInRect:afterScreenUpdates:. Check the method’s Boolean result: Apple says it returns false if image data is missing for any view in the hierarchy. Because Apple marks UIWebView deprecated, use WKWebView for new or maintained code, with its asynchronous snapshot API.

Capture a UIWebView screenshot after JavaScript runs

The order matters: make the page change, establish that the change is ready to display, and only then take the image. A JavaScript call returning does not prove that unrelated asynchronous page work, images, animations, or later script execution have finished. There is no universal sleep duration that reliably solves this; coordinate with a readiness signal meaningful to the page you control.

For a synchronous change—such as setting text or a style directly—the JavaScript evaluation can perform the change before capture begins. For a change that starts asynchronous work, arrange for the page or application to signal completion before calling the capture routine. UIKit’s afterScreenUpdates option concerns view updates; it is not a substitute for page-specific readiness.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Objective-C example for a synchronous visual change

This example updates an element, then captures the visible UIWebView bounds. Replace the selector and content with elements on a page you control. Call it on the main thread after the web view has loaded the page. It illustrates the API composition; it cannot guarantee that arbitrary page activity has completed.

#1 Best Overall
Guermok Video Capture Card, 4K USB3.0 HDMI to USB C, 1080P 60FPS & 2K 30FPS
  • 【1080P 60FPS Video Capture Card】 This HDMI game capture card is based on USB3.0 high speed transmission port, input resolution up to 4K@30HZ, output resolution up to 2K@30Hz or 1920×1080@60Hz. Type c and USB interface can meet most of the devices in daily life. Easily meet the online capture, real-time recording, online meetings, live gaming and other functions, so you have a better visual enjoyment. Note: For capture use only; requires capture software to function and is not intended for direct screen casting to a monitor or TV
  • 【Ultra Low Latency Screen Sharing】 HDMI capture card is made of good quality aluminum alloy with strong heat dissipation, allowing you to enjoy ultra low latency while live gaming or video recording or live streaming, avoiding blue screens and lag. This HDMI to USBC capture card supports easy recording of good quality audio or HD video and transferring it to your computer or streaming platform, allowing you to record 60 fps HD video directly on your hard drive and real-time preview
  • 【Plug and Play, Easy to Carry】 This HDMI 1080P video capture card does not require any additional drivers or external power supply, just plug and play for fast capture. The capture card is small and lightweight, so you can put it in your bag for emergencies, making it very portable for outdoor live streaming. It's also a great way to share content in game recording, video conference, video recorder and online teaching
  • 【Wide Compatibility USB Capture Card】 Easily streams to Facebook, Youtube or Twitch. With the connection, this HDMI to USB C/3.0 video capture devices can be working on several Operating Systems and various software: Windows 7/ 8/ 10, Mac OS or above, Linux, Android, Laptop, Xbox One, PS3/PS4/PS5, Camera, DVDs, Set Top Box, Webcame, DSLR, Switch/Switch 2, TV BOX, HDTV, Potplayer/VLC, ZOOM, OBS Studio etc.
  • 【Package Content & Note】 1x HD Audio Capture Card , 1x USB 3.0 to USB C Adapter (A-side 3.0, B-side 2.0), 1x user manual. Please note that you need to restart the OBS Studio software after the audio setup is complete, otherwise it will result in no sound output. When using an adapter, if the device is recognized as USB 2.0, try using the other side with the USB-C port. Simply flip the capture card and reconnect it to be recognized as USB 3.0
- (UIImage *)captureWebViewAfterSynchronousJavaScript:(UIWebView *)webView {
    NSAssert([NSThread isMainThread], @"UIKit view drawing must run on the main thread.");

    NSString *script = @"document.querySelector('#status').textContent = 'Ready';";
    [webView stringByEvaluatingJavaScriptFromString:script];

    UIGraphicsBeginImageContextWithOptions(webView.bounds.size, NO, 0.0);
    BOOL complete = [webView drawViewHierarchyInRect:webView.bounds
                                  afterScreenUpdates:YES];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    if (!complete || image == nil) {
        NSLog(@"The web view hierarchy snapshot may be incomplete.");
        return nil;
    }
    return image;
}

UIGraphicsBeginImageContextWithOptions creates the current image context; passing a scale of 0.0 uses the screen’s scale. The non-opaque setting is appropriate when the captured view may contain transparency. The method draws the receiver’s hierarchy as visible onscreen into that context, and UIGraphicsGetImageFromCurrentImageContext retrieves the resulting image. Always end the context, including when the drawing result is incomplete.

The example’s JavaScript assumes the page contains an element with ID status. If that selector does not match, the script will not make the intended change. For production code, also define how the app detects a JavaScript or page error, and decide how an incomplete image is reported or retried rather than silently using it.

When injected JavaScript starts asynchronous work

If the script fetches data, waits for an image, triggers a transition, or otherwise changes the page later, have code you control expose a completion signal only after the desired state is ready. The native app should wait for that signal and then capture. A page-specific callback, a checked state value, or a controlled bridge between page and app can serve this purpose; select one that reflects the actual visual work involved.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Video Capture Card, 4K USB3.0 HDMI to USB C, 1080P60FPS HDMI Capture Card for Streaming, Gaming, Video Recording Compatible with Switch, Xbox, PS4/5, OBS,iPad Mac OS Windows,Camera, Zoom(Silver)
  • 【4K HDMI Input, 2K@30Hz Recording】Powered by a true USB 3.0 high-speed interface, the capture card supports up to 4K@30Hz HDMI input and records at 2K@30Hz or 1080P@60Hz. Perfect for gamers, streamers, and professionals who need crisp, smooth video for live streaming, gameplay recording, or online meetings.
  • 【Ultra Low Latency Screen Sharing】Built with a premium aluminum alloy shell and advanced chipset for stable heat dissipation, ensuring ultra-low latency transmission. Capture high-quality video and dual-channel audio in real time—no lag, no frame drop—ideal for Twitch, YouTube, or OBS streaming.
  • 【Easy Plug and Play, Compact & Portable】No driver or external power required—just plug and play via USB 3.0 or Type-C connection to your Windows or macOS computer. Lightweight and compact design makes it easy to carry for outdoor streaming, live shows, or mobile recording setups.
  • 【Wide Compatibility & Multi-Device Support】Compatible with Windows 7 8 10 11, macOS, Linux,Android and supports most popular software such as OBS, Zoom, VLC, Twitch Studio, and more. Works seamlessly with PS4, PS5, Xbox, Switch, DSLR cameras, TV boxes, and other HDMI-output devices for streaming to YouTube, Twitch, etc.
  • 【What You Get】Includes: HDMI Capture Card, USB 3.0 to USB-C Adapter, User Manual. Tips: Make sure your tablet’s OTG function is enabled before connecting. Test your HDMI device with a monitor first to confirm video and audio output, then connect to the Video Capture Card for recording.

Do not treat a fixed delay, the end of stringByEvaluatingJavaScriptFromString:, or afterScreenUpdates:YES as proof that every image, animation, network request, or timer has settled. If you cannot coordinate readiness, the image may reflect an intermediate state. Test the particular page and content types your app supports, and inspect the output.

What this UIWebView capture includes—and what it does not

drawViewHierarchyInRect:afterScreenUpdates: draws the visible view hierarchy into the current graphics context. For a screenshot of only the webpage, use the UIWebView as the drawing receiver and its bounds as the rectangle. If you draw a containing native view instead, its visible hierarchy may also include surrounding app controls, which is useful only when those controls belong in the image.

This is not documented as a full-document, offscreen webpage export. A page longer than the visible web view is not automatically captured in its entirety by drawing the visible bounds. Likewise, setting afterScreenUpdates:YES asks UIKit to include recent view changes; it does not scroll the page, finish network activity, or make animations complete.

Rank #3
Sale
UGREEN 2K@30Hz 1080P 60FPS Video Capture Card 4K Input HDMI to USB 3.0
  • 2K 30FPS & 1080p 60FPS HDMI Capture Card: The 4K@30Hz input and 2K@30Hz output resolutions offer dual benefits. The high input resolution preserves original video quality for post-production editing, while the 2K output provides an optimal balance between clarity and compatibility. At the same time, this HDMI to USB-C capture card is also backward compatible with 1080p 60FPS, to fulfill a variety of daily needs. Note: Ensure your HDMI source device and the capture device support 2K resolution
  • Low Latency 5 Gbps High Data Transfer Speed: With high-speed USB 3.0 technology for optimal performance and low delay, you can easily stream video from the Switch/Switch 2/PS4/PS5 to Twitch, YouTube, Facebook, Twitter, OBS, Potplayer, and VLC on a computer. It's also backward compatible with USB 2.0. Note: This capture card for streaming only supports HDMI input sources, as well as iPadOS devices need to be updated to 17 or higher to use it
  • USB A and USB C ports: Featuring both USB-A and USB-C interfaces, this streaming capture card ensures broad compatibility with modern devices, including smartphones, laptops, tablets, desktops, and Quest 3. Perfect for multi-scenario streaming—whether you're broadcasting camera footage, mobile gaming, or PC live streams. Note: This capture card only supports unidirectional signal flow—HDMI input to USB output
  • Universal Compatibility: This Driver-Free HDMI capture card for streaming supports Windows 11/10/8.1/7, MacOS, Linux, and phones/tablets. This capture card effortlessly livestreams gameplay from Switch, Switch 2, PS4/PS4 Pro/PS5 (Disable HDCP mode), Xbox Series X, and Meta Quest 3/2 directly to your iPad, laptop, or PC. Fully support OBS Studio, XSplit, PotPlayer, QuickTime Player, and more for streaming, recording, editing, and high-res video transfer. Note: iPadOS 17 or later is required for USB-C iPad compatibility. Switch / Xbox / PS5/ PS4 work fine when HDCP is turned off
  • Durable USB Capture Card: The aluminum alloy casing easily dissipates heat and is lightweight while effectively shielding against EMI, ensuring stable signal transmission. The built-in cable features 26AWG (2C) + 30AWG (1P) tinned copper conductors, ensuring excellent conductivity and corrosion resistance, enhancing durability, and reducing signal loss

Check the returned Boolean. Apple documents false when the snapshot is missing image data for any view in the hierarchy. Treat that as a signal the result may be incomplete. The call is slower than snapshotViewAfterScreenUpdates:, which returns a snapshot view rather than directly drawing a bitmap; for a bitmap image, hierarchy drawing is the relevant operation here.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For maintained apps, use WKWebView

Apple marks UIWebView deprecated and says to use WKWebView instead. Apple’s documentation also says to use WKWebView in apps running iOS 8 and later. The newer web view provides JavaScript evaluation through evaluateJavaScript:completionHandler: and an asynchronous image capture API, takeSnapshotWithConfiguration:completionHandler:.

The WKWebView sequence is: wait for navigation or a page-specific ready condition, evaluate the script, wait for any asynchronous visual changes it triggers, and then request a snapshot. Handle both the image and any reported error in the completion handler. A completed JavaScript evaluation alone still does not mean every subsequent visual change is finished.

Rank #4
WARRKY Video Capture Card with 100W Power Delivery, USB 3.0 1080P 60HZ HD
  • [Exclusively Design] The L-shaped USB-C connector fits perfectly with Quest and iPad, while the extended cable design allows quick access to the connection port without removing the headset. Elevate your content with the WARRKY capture card through 4K@30fps input and 1080P@60fps recording. The YUY2 format delivers richer colors than MJPEG, eliminating banding with vibrant gradients for true-to-life streaming.
  • [100W High Speed Charging] Engineered for uninterrupted creativity, this capture card unleashes 100W ultra-fast charging through PD3.0 technology - simultaneously powering your Quest 3 and iPad while capturing gameplay or live streams. Never let a low battery interrupt your winning streak: the intelligent power management sustains stable voltage even during graphic-intensive VR battles or multi-hour broadcasts.
  • [Engineered for Excellence] The WARRKY capture card redefines reliability with aerospace-grade aluminum housing and braided nylon cabling, housing the flagship MS2130 chipset that achieves industry-leading 0.05s transmission latency. Precision-machined aluminum alloy dissipates heat 40% faster than plastic shells, maintaining stability during VR marathons, while triple-shielded nylon cables resist tangling across mobile studio setups.
  • [Universal Compatibility] The capture card is compatible with Switch, PS5/4, cameras, laptops, and tablets. It supports a wide range of capture software and platforms like HDMI Link, MoniCon, OBS Studio, QuickTime, and YouTube, and works with Windows 7/8/8.1/10, MacOS, Linux, Android, and iPadOS 17+. Enjoy seamless integration and exceptional performance across almost all your devices.
  • [WARRKY] We are committed to delivering exceptional quality products that combine sophisticated design with affordable pricing, offering you the best solutions for seamlessly connecting your work and life. If you have any issues, please reach out to us at your convenience. Your satisfaction is our top priority.
// Objective-C outline: call on the main thread after the page is ready.
[webView evaluateJavaScript:@"document.querySelector('#status').textContent = 'Ready';"
          completionHandler:^(id result, NSError *javaScriptError) {
    if (javaScriptError) {
        NSLog(@"JavaScript evaluation failed: %@", javaScriptError);
        return;
    }

    // If the script triggers asynchronous visual work, wait for the page-specific
    // readiness signal here before requesting the snapshot.
    [webView takeSnapshotWithConfiguration:nil
                         completionHandler:^(UIImage *image, NSError *snapshotError) {
        if (snapshotError) {
            NSLog(@"Snapshot failed: %@", snapshotError);
            return;
        }
        if (image == nil) {
            NSLog(@"Snapshot completed without an image.");
            return;
        }
        // Use or save image here.
    }];
}];

This is a compact capture sequence, not a universal page-readiness implementation. For a page where the mutation starts asynchronous work, replace the comment with coordination tied to that page. A WKSnapshotConfiguration can specify the portion to capture; pass a configured instance when you need a region other than the default. The completion handler reports an image or an error, so handle both rather than assuming the operation always succeeds.

Consideration Legacy UIWebView WKWebView
Lifecycle Deprecated; Apple says to use WKWebView. Apple’s recommended replacement.
Capture mechanism Draw the visible hierarchy into a caller-managed graphics context. Asynchronously request a platform-native image with takeSnapshot.
Region Use the receiver’s visible bounds for the visible-view capture described here. WKSnapshotConfiguration specifies the portion to capture.
Completion signal Synchronous drawing returns a Boolean completeness indicator. Completion handler supplies an image or error.
Page readiness Coordinate separately when injected code causes asynchronous visual changes; neither capture approach defines a universal post-injection wait time.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting missing or stale JavaScript changes

  • The old page state appears: capture may be running before the mutation is rendered, or the mutation may run later than the capture. Confirm the script changed the intended element, then wait for the page-specific visual-ready signal before drawing.
  • The change appears only sometimes: a network response, image load, timer, or animation may finish at variable times. Replace timing guesses with a completion condition tied to that work, and test under the network and page conditions your app supports.
  • The image is incomplete: check whether drawViewHierarchyInRect:afterScreenUpdates: returned NO. Apple documents this return when image data is missing for a view in the hierarchy. Do not treat the Boolean as a guarantee that a page is semantically ready when it is YES.
  • Native controls appear in the result: the drawing receiver includes its visible hierarchy. Capture the web view itself if the target is only webpage content; choose a containing view only when surrounding native UI is intentional.
  • The screenshot cuts off a long page: this method is documented as drawing the hierarchy visible onscreen, not as a full-page webpage export. It captures the view region used for the draw rather than promising an offscreen document image.
  • WKWebView returns an error or no image: handle the snapshot completion error and check that an image was actually supplied. Keep page readiness separate from snapshot error handling: a technically successful capture can still occur before the desired page state.

Or skip the browser setup

If you need a screenshot of a publicly reachable webpage rather than a view embedded in your iOS app, ScreenshotNeo offers a website screenshot API and MCP server. It does not capture your app’s local UIWebView; use the UIKit or WebKit methods above for that. For an external webpage, one GET request can return PNG, JPEG, WebP, or PDF. The API accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with the result described by X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See the ScreenshotNeo API documentation for parameters. This cURL request saves a WebP screenshot of the target page:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Every feature is on every plan, and yearly billing gives two months free. Sign up for ScreenshotNeo’s free plan to try it without a card.

Best Value
Anker USB C to HDMI Adapter (4K@60Hz), USB Type C to HDMI Cable Adapter
  • The Anker Advantage: Join the 80 million+ powered by our leading technology.
  • Vivid Video: The HDMI adapter lets you connect to any TV or display with an HDMI port to stream video in up to 4K resolution.
  • Plug and Play: Instantly turn your laptop’s USB-C port into an HDMI port, with no installation necessary. This product does not support charging or Power Delivery (PD).
  • Premium Construction: A lightweight aluminum casing allows for greater heat dissipation, while the reinforced braided-nylon cable is designed to withstand the twists and tugs of daily use.
  • Compatibility: Supports USB-C DP Alt mode, USB4, and Thunderbolt connections.

FAQ

Does the UIWebView method return a UIImage?

The drawing call writes into the current graphics context. In the Objective-C example, UIGraphicsGetImageFromCurrentImageContext() retrieves the image produced there.

Frequently Asked Questions

Does the UIWebView method return a UIImage?

The drawing call writes into the current graphics context. Retrieve the resulting image with UIGraphicsGetImageFromCurrentImageContext().

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.