~~~
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIWebView * webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 20, ScreenWidth, ScreenHeight-20)];
// 自動隊頁面進行縮放以適應屏幕
webView.scalesPageToFit = YES;
webView.userInteractionEnabled = YES;
webView.opaque = YES;
[self.view addSubview:webView];
NSURL * url = [NSURL URLWithString:@"http://www.youku.com"];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
// NSString * myHT = @"優酷";
// [webView loadHTMLString:myHT baseURL:url];
/*
[webView goBack]; // 返回
[webView goForward]; // 前往
[webView reload];
[webView stopLoading];
*/
webView.delegate = self;
//移除滾動后的外邊陰影
UIScrollView *scrollView = webView.scrollView;
for (int i = 0; i < scrollView.subviews.count ; i++) {
UIView *view = [scrollView.subviews objectAtIndex:i];
if ([view isKindOfClass:[UIImageView class]]) {
view.hidden = YES ;
}
}
}
#pragma mark - UIWebViewDelegate
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
/**
* typedef NS_ENUM(NSInteger, UIWebViewNavigationType) {
* UIWebViewNavigationTypeLinkClicked,
* UIWebViewNavigationTypeFormSubmitted,
* UIWebViewNavigationTypeBackForward,
* UIWebViewNavigationTypeReload,
* UIWebViewNavigationTypeFormResubmitted,
* UIWebViewNavigationTypeOther
};
*/
NSLOG_FUNCTION;
return YES;
}
// 開始加載
- (void)webViewDidStartLoad:(UIWebView *)webView{
NSLOG_FUNCTION;
}
// 完成加載
- (void)webViewDidFinishLoad:(UIWebView *)webView{
NSLOG_FUNCTION;
}
// 加載失敗,彈出錯誤提示
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
UIAlertView *alterview = [[UIAlertView alloc] initWithTitle:@"" message:[error localizedDescription]
delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alterview show];
[alterview release];
NSLOG_FUNCTION;
}
~~~
- 前言
- UITableView詳解(UITableViewCell(一)重中之重)
- UITableView詳解(UITableViewCell(二) 自定義cell)
- UITableView詳解(UITableViewCell(三) cell根據文本長度來自動調整cell高度)
- UITableView詳解(UITableViewCell(四) 增加 刪除 移動)
- UITabBarController詳解(一)UITabBarController的介紹和設置(偷了點懶,直接用了ARC)
- UITabBarController詳解(二)UITabBarController的代理方法以及模態顯示
- UISearchBar詳解(一)基本屬性
- UISearchBar詳解(二)數據刷選類:NSPredicate
- UISearchDisplayController 的使用
- UINavigationController詳解(一)
- UINavigationController詳解(二)UINavigationBar(UIBarButtonItem)
- UINavigationController詳解(三)UIToolBar
- UINavigationController詳解(四)iOS7新特性
- UIScrollView控件詳解
- UISwitch用法-以及-自定義UISwitch控件
- UIAlertView用法
- UILabel 的常見屬性和方法:
- UIPickerView(滾動選擇控制器)
- UIActivityIndicatorView(活動指示器 ---------> 網絡卡后加載,畫面,圖像加載閃爍的圓圈)
- UIStepper
- UIImagePickerController--------圖片選取器
- UITextView
- UITabBarController詳解(三)自定義UITabBarController
- UIWebView基本介紹