007 create an ios6.0 application on xcode4.5 (Web View Control webview)

Source: Internet
Author: User
Webpage view control webview: code is directly used for webpage view controls, because you have written precautions for using the controls in the code.
Viewcontroller. h
@interface ViewController : UIViewController <UIWebViewDelegate>{    IBOutlet UITextField * myTextFiedld;    IBOutlet UIWebView * myWebView;}@property (nonatomic,retain)UITextField * myTextFiedld;@property (nonatomic,retain)UIWebView * myWebView;-(IBAction)changeLocation:(id)sender;@end
Viewcontroller. m
@ Implementation viewcontroller @ synthesize mytextfiedld; @ synthesize mywebview; // button click event-(ibaction) changelocation :( ID) sender {mywebview. delegate = self; // Note: You must set the delegate [mytextfiedld resignfirstresponder]; // discard the first responder // build the URL object nsurl * url = [nsurl urlwithstring through the input text: mytextfiedld. text]; // construct the response object nsurlrequest * Req = [nsurlrequest requestwithurl: url] through the URL object; // pass the response object to [mywebview loadrequest: req] in the Web View;} // The browser load completion event-(void) webviewdidfinishload :( uiwebview *) webview {nslog (@ "finsh... "); // This method can execute a Javascript script nsstring * s = [mywebview stringbyevaluatingjavascriptfromstring: @" document.doc umentelement. textcontent "]; nslog (@" % @ ", S) ;}// events that fail to load the browser-(void) webview :( uiwebview *) webview didfailloadwitherror :( nserror *) error {nslog (@ "error... "); // nserror objects will be used frequently in the future and are very useful. Nslog (@ "% @", [error description]);}-(void) viewdidload {[Super viewdidload]; // do any additional setup after loading the view, typically from a nib .} -(void) didreceivememorywarning {[Super didreceivemorywarning]; // dispose of any resources that can be recreated .} -(void) dealloc {[mytextfiedld release]; [mywebview release]; [Super dealloc];} @ end


Note: The method of the control

Code Implementation

Source code of Baidu printed by calling Javascript in the background


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.