您好,我在通过 Safari 打开 Web 链接时遇到了问题。这是我的代码
标题
#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)Web:(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 {
应该是
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
您不能更改委托(delegate)方法的签名并期望它被调用。
关于iphone - 使用 webview 通过 safari 打开链接的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5256937/