iphone - 使用 webview 通过 safari 打开链接的问题

标签 iphone xcode ios uiwebview

您好,我在通过 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/

相关文章:

ios - 将文件类型与我的iOS应用程序关联:文件无图像

ios - 在相机上捕获屏幕

ios - 从字符串数组填充 Collection View 单元格标签的最简单方法是什么?

ios - Xcode 没有在断点处停止

ios - 谷歌地图模糊使用 GMSMapView 类型

ios - 当触摸位于不同的 subview 中时, super View 上的 UIPinchGestureRecognizer 不会尝试识别捏合

iphone - 在 iOS 中将图像元数据写入 JPG/PNG 文件

android - Android/iPhone 图像识别

iphone - Core Data 将数据移动到共享容器中

ios - Urban Airship 集成错误 arm64 不是被链接的架构 (armv7)