IOS UIWebView webpage View

Source: Internet
Author: User

Today, when I was working on a project, I used the UIWebView class to browse the Web page.
Let's take a look at what this class has.
In fact, this class is relatively simple.

UIWebViewInherited from UIView
This class can be used to easily implement web browsing.

Next, let's take a look at the attributes.
@ Property (nonatomic, assign) id Delegate // the proxy of the class

@ Property (nonatomic, readonly, retain) NSURLRequest * request
// URL request for the currently displayed page

@ Property (nonatomic, readonly, getter = isLoading) BOOLloading
// Whether the current webpage is loading

@ Property (nonatomic, readonly, getter = canGoBack) BOOLcanGoBack
// Whether the previous page can be returned from the current page
@ Property (nonatomic, readonly, getter = canGoForward) BOOLcanGoForward
// Whether the current webpage can be moved forward

@ Property (nonatomic) BOOL scalesPageToFit
// Whether the webpage content is adaptive

@ Property (nonatomic, readonly, retain) UIScrollView * scrollView
// Scroll view associated with the current web View

@ Property (nonatomic) BOOL suppressesIncrementalRendering
// Whether the web View is rendered after the webpage content is downloaded. The default value is NO.

@ Property (nonatomic) BOOL keyboardDisplayRequiresUserAction
// Whether to respond to user input on the web page. The default value is YES.

@ Property (nonatomic) UIDataDetectorTypes dataDetectorTypes
// Convert the content on the webpage into clickable links
Enum {
UIDataDetectorTypePhoneNumber = 1 <0,
UIDataDetectorTypeLink = 1 <1,
UIDataDetectorTypeAddress = 1 <2,
UIDataDetectorTypeCalendarEvent = 1 <3,
UIDataDetectorTypeNone = 0,
UIDataDetectorTypeAll = NSUIntegerMax
};

@ Property (nonatomic) BOOL allowsInlineMediaPlayback
// This value determines whether to use built-in HTML5 to play a video or local full screen control.
To embed video playback, you not only need to set this attribute on this page,
It is also required that the video element in HTML must contain the webkit-playsinline attribute. The default value is NO.

@ Property (nonatomic) BOOL mediaPlaybackRequiresUserAction
// Enable YES on the iPhone and iPad by default. This value determines whether the HTML5 video can be automatically played or the user needs to start playing.
@ Property (nonatomic) BOOL mediaPlaybackAllowsAirPlay
// This value determines whether Air Play is available from this page. YES is used by default on the iPhone and iPad.

Let's take a look at the method below

Load data
-(Void) loadRequest :( NSURLRequest *) request
// Load URL Data Request

-(Void) loadHTMLString :( NSString *) string baseURL :( NSURL *) baseURL
// Set the homepage. The content of the homepage is the content of the baseURL link.

-(Void) loadData :( NSData *) data MIMEType :( NSString *) MIMEType textEncodingName :( NSString *) encodingName baseURL :( NSURL *) baseURL
// Set the homepage content, MIME type, encoded content, and basic URL.
// Data is the homepage content

-(Void) stopLoading // stop loading data
-(Void) reload // load the current page data

Webpage Switching

-(Void) goBack // return a page
-(Void) goForward // forward one page

Run the Java Script

-(NSString *) stringByEvaluatingJavaScriptFromString :( NSString *) script
// Return the result of running the script language.
The execution time of JavaScript is limited to 10 seconds. If the execution time exceeds 10 seconds, the page stops executing the script.
JavaScript execution may block the main thread, so when the script is executed, the user is not allowed to affect page loading.
The memory allocation of JavaScript is limited to 10 MB. If the limit is exceeded, an exception occurs on the page.


So far, this is the method of all the attributes of the UIWebView class, and it is easy to understand.
One thing is that the last method is not very clear. I will continue to study it. If you know, please let me know.

Today -- LC








Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.