How iPhone calls the web

1. Call the iPhone application

Call your own mail

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]];

  call phone

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];

  Call SMS

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];

  Call the built-in browser safari

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];

  The above is the most basic statement, there is no processing.

  For example: Calling phone can pass the number, calling SMS can only set the number, and cannot initialize the SMS content.

  ps: According to Apple's agreement, using any call other than the browser does not comply with the user regulations, so it is difficult to pass the App Store, use with caution.

2. The use of UIViewController

Build a WebViewController inherited from UIViewController<UIWebViewDelegate>, as a page that needs to pop up. code show as below:

h file:

#import <UIKit/UIKit.h>


@interface WebViewController : UIViewController <UIWebViewDelegate>{

    UIWebView *myWebView;

    NSString* url;

}


@property(nonatomic, retain) IBOutlet UIWebView *myWebView;

@property(nonatomic, retain) NSString* url;


@end

The more important code sentences in the m file are actually the methods that need to be rewritten in UIWebViewDelegate:

- (void)webViewDidStartLoad:(UIWebView *)webView{

//start load

}


- (void)webViewDidFinishLoad:(UIWebView *)webView{

   //load finished

}


- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{

   //load fail

[self.myWebView loadHTMLString:[NSString stringWithFormat:@"<html><body>%@</body></html>",[error description]] baseURL:nil];

}


References:

http://www.cnmsdn.com/html/201003/1268756224ID2080.html


Guess you like

Origin blog.csdn.net/rsp19801226/article/details/7305042