UIWebView的高级用法二

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;
}

#import "BaseViewController.h"

@interface BaseViewController ()
{
    UIWebView *webview;
}

@end

@implementation BaseViewController

#pragma  mark -life cicry


- (void)viewDidLoad
{
    [super viewDidLoad];
    webview=[[UIWebView alloc] initWithFrame:self.view.bounds];
    webview.delegate=self;//因为这个代理设置的self
    [self.view addSubview:webview];
    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.requestUrl]]];

    [webview release];
    UIScrollView *scollview=(UIScrollView *)[[webview subviews]objectAtIndex:0];
    scollview.bounces=NO;

    // Do any additional setup after loading the view.
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)viewDidUnload{
    [super viewDidUnload];
    self.requestUrl=nil;
}

- (void)dealloc
{
    [_requestUrl release];
    [super dealloc];
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值