1、 調用iPhone應用程序
調用 自帶mail
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]];
調用 電話phone
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8008808888"]];
調用 SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]];
調用自帶 瀏覽器 safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.hzlzh.com"]];
上面是最基本的語句,沒什麼處理過程。
如:調用phone可以傳遞號碼,調用SMS 只能設定號碼,不能初始化SMS內容。
ps:根據Apple的協議,使用 調用瀏覽器以外的任何調用,都不符合用戶條例,因此,較難通過 App Store,慎用。
2、UIViewController 的使用
自建一個WebViewController繼承於UIViewController<UIWebViewDelegate>,作爲需要彈出的一個頁面。代碼如下:
h文件:
#import <UIKit/UIKit.h>
@interface WebViewController : UIViewController <UIWebViewDelegate>{
UIWebView *myWebView;
NSString* url;
}
@property(nonatomic, retain) IBOutlet UIWebView *myWebView;
@property(nonatomic, retain) NSString* url;
@end
m文件其中比較重要的代碼句, 實際就是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];
}
參考資料:
http://www.cnmsdn.com/html/201003/1268756224ID2080.html