Class: UIWebView
Overview
You use the UIWebView class to embed web content in your application. To do so, you simply create a UIWebView object, attach it to a window, and send it a request to load web content. You can also use this class to move back and forward in the history of webpages, and you can even set some web content properties programmatically.
Instance Attribute Summary (collapse)
-
- allowsInlineMediaPlayback
A Boolean value that determines whether HTML5 videos play inline or use the native full-screen controller.
-
- canGoBack
readonly
A Boolean value indicating whether the receiver can move backward.
-
- canGoForward
readonly
A Boolean value indicating whether the receiver can move forward.
-
- dataDetectorTypes
The types of data converted to clickable URLs in the web view’s content.
-
- delegate
The receiver’s delegate.
-
- keyboardDisplayRequiresUserAction
A Boolean value indicating whether web content can programmatically display the keyboard.
-
- loading
readonly
A Boolean value indicating whether the receiver is done loading content.
-
- mediaPlaybackAllowsAirPlay
A Boolean value that determines whether Air Play is allowed from this view.
-
- mediaPlaybackRequiresUserAction
A Boolean value that determines whether HTML5 videos can play automatically or require the user to start playing them.
-
- request
readonly
The URL request identifying the location of the content to load.
-
- scalesPageToFit
A Boolean value determining whether the webpage scales to fit the view and the user can change the scale.
-
- scrollView
readonly
The scroll view associated with the web view.
-
- suppressesIncrementalRendering
A Boolean value indicating whether the web view suppresses content rendering until it is fully loaded into memory.
Attributes inherited from UIView
#alpha, #autoresizesSubviews, #autoresizingMask, #backgroundColor, #bounds, #center, #clearsContextBeforeDrawing, #clipsToBounds, #contentMode, #contentScaleFactor, #exclusiveTouch, #frame, #gestureRecognizers, #hidden, #layer, #multipleTouchEnabled, #opaque, #restorationIdentifier, #subviews, #superview, #tag, #transform, #userInteractionEnabled, #window
Attributes inherited from UIResponder
#inputAccessoryView, #inputView, #undoManager
Instance Method Summary (collapse)
-
- goBack
Loads the previous location in the back-forward list.
-
- goForward
Loads the next location in the back-forward list.
-
- 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.
-
- reload
Reloads the current page.
-
- stopLoading
Stops the loading of any web content managed by the receiver.
-
- stringByEvaluatingJavaScriptFromString:
Returns the result of running a script.
Methods inherited from UIView
#addConstraint:, #addConstraints:, #addGestureRecognizer:, #addSubview:, #alignmentRectForFrame:, #alignmentRectInsets, animateWithDuration:animations:, animateWithDuration:animations:completion:, animateWithDuration:delay:options:animations:completion:, areAnimationsEnabled, beginAnimations:context:, #bringSubviewToFront:, commitAnimations, #constraints, #constraintsAffectingLayoutForAxis:, #contentCompressionResistancePriorityForAxis:, #contentHuggingPriorityForAxis:, #convertPoint:fromView:, #convertPoint:toView:, #convertRect:fromView:, #convertRect:toView:, #decodeRestorableStateWithCoder:, #didAddSubview:, #didMoveToSuperview, #didMoveToWindow, #drawRect:, #drawRect:forViewPrintFormatter:, #encodeRestorableStateWithCoder:, #endEditing:, #exchangeSubviewAtIndex:withSubviewAtIndex:, #exerciseAmbiguityInLayout, #frameForAlignmentRect:, #gestureRecognizerShouldBegin:, #hasAmbiguousLayout, #hitTest:withEvent:, #initWithFrame:, #insertSubview:aboveSubview:, #insertSubview:atIndex:, #insertSubview:belowSubview:, #intrinsicContentSize, #invalidateIntrinsicContentSize, #isDescendantOfView:, layerClass, #layoutIfNeeded, #layoutSubviews, #needsUpdateConstraints, #pointInside:withEvent:, #removeConstraint:, #removeConstraints:, #removeFromSuperview, #removeGestureRecognizer:, requiresConstraintBasedLayout, #sendSubviewToBack:, setAnimationBeginsFromCurrentState:, setAnimationCurve:, setAnimationDelay:, setAnimationDelegate:, setAnimationDidStopSelector:, setAnimationDuration:, setAnimationRepeatAutoreverses:, setAnimationRepeatCount:, setAnimationStartDate:, setAnimationTransition:forView:cache:, setAnimationWillStartSelector:, setAnimationsEnabled:, #setContentCompressionResistancePriority:forAxis:, #setContentHuggingPriority:forAxis:, #setNeedsDisplay, #setNeedsDisplayInRect:, #setNeedsLayout, #setNeedsUpdateConstraints, #setTranslatesAutoresizingMaskIntoConstraints:, #sizeThatFits:, #sizeToFit, #systemLayoutSizeFittingSize:, transitionFromView:toView:duration:options:completion:, transitionWithView:duration:options:animations:completion:, #translatesAutoresizingMaskIntoConstraints, #updateConstraints, #updateConstraintsIfNeeded, #viewForBaselineLayout, #viewPrintFormatter, #viewWithTag:, #willMoveToSuperview:, #willMoveToWindow:, #willRemoveSubview:
Methods inherited from UIResponder
#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Instance Attribute Details
- (Boolean) allowsInlineMediaPlayback
A Boolean value that determines whether HTML5 videos play inline or use the native full-screen controller. The default value on iPhone is NO.In order for video to play inline, not only does this property need to be set on the view, but the video element in the HTML document must also include the webkit-playsinline attribute.
- (Boolean) canGoBack (readonly)
A Boolean value indicating whether the receiver can move backward. (read-only) If YES, able to move backward; otherwise, NO.
- (Boolean) canGoForward (readonly)
A Boolean value indicating whether the receiver can move forward. (read-only) If YES, able to move forward; otherwise, NO .
- (UIDataDetectorTypes) dataDetectorTypes
The types of data converted to clickable URLs in the web view’s content. You can use this property to specify the types of data (phone numbers, http links, email address, and so on) that should be automatically converted to clickable URLs in the web view. When clicked, the web view opens the application responsible for handling the URL type and passes it the URL.
- (Object) delegate
The receiver’s delegate. The delegate is sent messages when content is loading. See UIWebViewDelegate Protocol Reference for the optional methods this delegate may implement.Important: Before releasing an instance of UIWebView for which you have set a delegate, you must first set its delegate property to nil. This can be done, for example, in your dealloc method.
- (Boolean) keyboardDisplayRequiresUserAction
A Boolean value indicating whether web content can programmatically display the keyboard. When this property is set to YES, the user must explicitly tap the elements in the web view to display the keyboard (or other relevant input view) for that element. When set to NO, a focus event on an element causes the input view to be displayed and associated with that element automatically. The default value for this property is YES.
- (Boolean) loading (readonly)
A Boolean value indicating whether the receiver is done loading content. (read-only) If YES, the receiver is still loading content; otherwise, NO.
- (Boolean) mediaPlaybackAllowsAirPlay
A Boolean value that determines whether Air Play is allowed from this view. The default value on both iPad and iPhone is YES.
- (Boolean) mediaPlaybackRequiresUserAction
A Boolean value that determines whether HTML5 videos can play automatically or require the user to start playing them. The default value on both iPad and iPhone is YES.
- (NSURLRequest) request (readonly)
The URL request identifying the location of the content to load. (read-only)
- (Boolean) scalesPageToFit
A Boolean value determining whether the webpage scales to fit the view and the user can change the scale. If YES, the webpage is scaled to fit and the user can zoom in and zoom out. If NO, user zooming is disabled. The default value is NO.
- (UIScrollView) scrollView (readonly)
The scroll view associated with the web view. (read-only) Your application can access the scroll view if it wants to customize the scrolling behavior of the web view.
- (Boolean) suppressesIncrementalRendering
A Boolean value indicating whether the web view suppresses content rendering until it is fully loaded into memory. When set to YES, the web view does not attempt to render incoming content as it arrives. Instead, the view’s current contents remain in place until all of the new content has been received, at which point the new content is rendered. This property does not affect the rendering of content retrieved after a frame finishes loading. The value of this property is NO by default.
Instance Method Details
- (Object) goBack
Loads the previous location in the back-forward list.
- (Object) goForward
Loads the next location in the back-forward list.
- (Object) loadData(data, MIMEType:MIMEType, textEncodingName:encodingName, baseURL:baseURL)
Sets the main page contents, MIME type, content encoding, and base URL.
- (Object) loadHTMLString(string, baseURL:baseURL)
Sets the main page content and base URL.
- (Object) loadRequest(request)
Connects to a given URL by initiating an asynchronous client request. To stop this load, use the stopLoading method. To see whether the receiver is done loading the content, use the loading property.
- (Object) reload
Reloads the current page.
- (Object) stopLoading
Stops the loading of any web content managed by the receiver. Stops any content in the process of being loaded by the main frame or any of its children frames. Does nothing if no content is being loaded.
- (String) stringByEvaluatingJavaScriptFromString(script)
Returns the result of running a script. JavaScript execution time is limited to 10 seconds for each top-level entry point. If your script executes for more than 10 seconds, the web view stops executing the script. This is likely to occur at a random place in your code, so unintended consequences may result. This limit is imposed because JavaScript execution may cause the main thread to block, so when scripts are running, the user is not able to interact with the webpage.JavaScript allocations are also limited to 10 MB. The web view raises an exception if you exceed this limit on the total memory allocation for JavaScript.