@implementation ViewController
NSString *urlString = @"http://ad.hodomobile.com/webad/release_320x50.php";
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[self.mywebView loadRequest:request];
[self.view addSubview:_mywebView];
self.mywebView.scalesPageToFit = YES;
self.mywebView.delegate = self;
}
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType{
if(navigationType == UIWebViewNavigationTypeOther)
{
[[UIApplication sharedApplication] openURL: request.URL];
return NO;
}
return YES;
}
想請問網址是一個廣告banner,我用webView做顯示,要點擊後彈出瀏覽器呈現網站,
但是跑模擬器時,卻廣告還沒出來,也還沒點擊,就直接彈出瀏覽器顯示廣告,是哪個地方我有寫錯了嗎....
底下這整段刪掉試看看...
- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType{
if(navigationType == UIWebViewNavigationTypeOther)
{
[[UIApplication sharedApplication] openURL: request.URL];
return NO;
}
return YES;
}