Introduction to basic usage methods of WebView in iOS development

Source: Internet
Author: User

#import<Foundation/Foundation.h>intMainintargcChar Const*argv[]) {    //Reference Address:HTTP://UBLUESKY.COM/ARCHIVES/55    //Nsurl Initialization method:Nsurl *url=[nsurl urlwithstring:@"http://www.ubluesky.com?id=1"]; //Solution for urlwithstring initialization failureNSString *strlocalhtml =@"file:///Users/amarishuyi/Desktop/My IPhone life/webdeveloper/webplug-in/exteditor/datapage/kmqt/ Ext-htmleditor.html"; Strlocalhtml= [NSString stringWithFormat:@"%@? value=%@", Strlocalhtml,self.txturl.text]; Strlocalhtml=[strlocalhtml stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; Nsurl* Url=[Nsurl urlwithstring:strlocalhtml]; //Solution for Fileurlwithpath initialization failureSelf.filepathstring =[self.filepathstring stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]; Nsurl*url =[Nsurl fileURLWithPath:self.filePathString]; //Nsurl parameters that can be obtained after successful initializationNsurl *url = [Nsurl urlwithstring:@"http://www.baidu.com/s?tn=baiduhome_pg&bs=nsrul&f=8&rsv_bp=1&rsv_spt=1&wd=nsurl& inputt=2709"]; NSLog (@"Scheme:%@", [URL scheme]); NSLog (@"Host:%@", [url host]); NSLog (@"Port:%@", [url port]); NSLog (@"Path:%@", [url path]); NSLog (@"Relative Path:%@", [url relativepath]); NSLog (@"Path Components as array:%@", [url pathcomponents]); NSLog (@"Parameter string:%@", [url parameterstring]); NSLog (@"Query:%@", [url query]); NSLog (@"Fragment:%@", [url fragment]); NSLog (@"User:%@", [url user]); NSLog (@"Password:%@", [url password]); //get the path to the package content file based on the file name and file suffixNsurl *urlkindeditor = [[Nsbundlemainbundle]urlforresource:@" Simple"Withextension:@"HTML"subdirectory:@"Kindeditor/examples"]; //urlforresource: File name//withextension: File suffix//subdirectory: Find in which subdirectory in the package. //Nil will be returned if not found//when found, return to the following path: file://localhost/users/amarishuyi/library/application%20support/iphone%20simulator/5.1/applications/ Fb0cdabc-d0e2-45ff-aa2c-959e8a65adb4/smalldemolist.app/kindeditor/examples/simple.html//compare two URLs for equality[url isequal:[_audioplayer url]]; //Although the iphone does not allow two applications to run at the same time, we can launch another application from within our own application and share data between applications. //we can use the UIApplication class's OpenURL: method to start another application from one application. //For example, to open the Google home page in the Safari app, we could write the following code:Nsurl *url = [Nsurl urlwithstring:@"http://google.com"];      [[UIApplication sharedapplication] openurl:url]; //here's the http://part is called a URL scheme (URL scheme), which represents the application you want to load. //There are several URL schemes for native iphone applications, and you can launch them in a similar way. //For example, to start the mail application (shown in 3-15), we can use:Nsurl *url = [Nsurl urlwithstring:@ "Mailto:[email protected] subject=test "];          [[UIApplication sharedapplication] openurl:url]; //to start the SMS application, we can write the following code:Nsurl*url = [Nsurl urlwithstring:@"sms:555-1234"];          [[UIApplication sharedapplication] penurl:url]; //to dial a phone number, we can use the following code:Nsurl*url=[nsurl urlwithstring:@"tel://555-1234"];          [[UIApplication sharedapplication] openurl:url]; //to launch the Maps app to find a pizzeria (shown in 3-16), we use the following code:Nsurl*url = [Nsurl urlwithstring:@"Http://maps.google.com/maps?q=pizza"];          [[UIApplication sharedapplication] openurl:url]; //We can also use the URL scheme to launch our own applications://use a custom URL scheme to launch the application://1) Create a new view-based application and save it as urlschemeexample. //2) in the Xcode Groups & Files Panel, expand the Resource section and select the <app>-info.plist file. //3) Right click on the Information Property list key and click the add arrow to select "URL types" from the list (3-17). //4) Expand Item 1, right-click the URL identifier, and select Add arrow again to select the URL from the list    return 0;}

Introduction to basic usage methods of WebView in iOS development

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.