hi i had encounter a problem opening a web link through safari. this is my code
header
#import <UIKit/UIKit.h>
@interface qrcode_info : UIViewController <UIWebViewDelegate,UIAlertViewDelegate> {
}
@property (nonatomic, retain) IBOutlet UIWebView *Web;
@end
//main file
#import "qrcode_info.h"
@implementation qrcode_info
@synthesize Web;
-(BOOL)We开发者_开发技巧b:(UIWebView *)Web shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:[request URL]];
return NO;
}
return YES;
}
//[[UIApplication sharedApplication] openURL:[inRequest URL]];
//return NO;
- (void)viewDidLoad {
[super viewDidLoad];
[Web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"help" ofType:@"html"] isDirectory:NO]]];
//self.wvTutorial = [[WebViewController alloc] initWithNibName:@”WebView” bundle:[NSBundle mainBundle]];
}
-(BOOL)Web:(UIWebView *)Web shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
should be
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
You can't change the signature of a delegate method and expect it to be called.
精彩评论