webView 高級用法 一
1.隱藏上下滾動時出邊界的後面的黑色的陰影
- (void) hideGradientBackground:(UIView*)theView
{
for (UIView * subview in theView.subviews)
{
if ([subview isKindOfClass:[UIImageView class]])
subview.hidden = YES;
[self hideGradientBackground:subview];
}
}
2. 禁用拖拽時的反彈效果
[(UIScrollView *)[[webView subviews] objectAtIndex:0] setBounces:NO];
3. 判斷用戶點擊類型
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
switch (navigationType)
{
//點擊連接
case UIWebViewNavigationTypeLinkClicked:
{
NSLog(@"clicked");
}
break;
//提交表單
case UIWebViewNavigationTypeFormSubmitted:
{
NSLog(@"submitted");
}
default:
break;
}
return YES;
}
- (void) hideGradientBackground:(UIView*)theView
{
for (UIView * subview in theView.subviews)
{
if ([subview isKindOfClass:[UIImageView class]])
subview.hidden = YES;
[self hideGradientBackground:subview];
}
}
2. 禁用拖拽時的反彈效果
[(UIScrollView *)[[webView subviews] objectAtIndex:0] setBounces:NO];
3. 判斷用戶點擊類型
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
switch (navigationType)
{
//點擊連接
case UIWebViewNavigationTypeLinkClicked:
{
NSLog(@"clicked");
}
break;
//提交表單
case UIWebViewNavigationTypeFormSubmitted:
{
NSLog(@"submitted");
}
default:
break;
}
return YES;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.