web使用

contentWeb =  [[UIWebViewalloc] initWithFrame:CGRectMake(10, 0, 300, 135)];

        contentWeb.layer.cornerRadius = 8;

        contentWeb.layer.masksToBounds = YES;

        contentWeb.dataDetectorTypes = UIDataDetectorTypeNone;//去掉下划线

//        contentView.scalesPageToFit = YES;

        contentWeb.backgroundColor = [UIColorclearColor];

        [self addSubview:contentWeb];

        contentWeb.hidden = YES;

        UIScrollView *scroller = [contentWeb.subviews objectAtIndex:0];//去掉上下阴影

        if (scroller) {

            for (UIView *v in [scroller subviews]) {

                if ([v isKindOfClass:[UIImageView class]]) {

                    [v removeFromSuperview];

                    }

               }

        }

 

- (BOOL)webView:(UIWebView *)webViewLocal shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 

{

NSString *myURL = [[request URL] absoluteString];

    //    NSLog(@"%@", myURL);//进来时:about:blank  http://www.baidu.com/

    if([myURL hasPrefix:@"http:"])

{

        //        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:(NSString *)[myURL substringFromIndex:[@"http:" length]]]];

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:myURL]];

        return NO;

    }

return YES;

}

posted @ 2013-01-05 11:24  燕羽天空  Views(135)  Comments(0Edit  收藏  举报