~~~
- (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基本介绍