Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
打开从UIWebView到Safari(iphone)的链接_Iphone_Uiwebview_Mobile Safari_Hyperlink - Fatal编程技术网

打开从UIWebView到Safari(iphone)的链接

打开从UIWebView到Safari(iphone)的链接,iphone,uiwebview,mobile-safari,hyperlink,Iphone,Uiwebview,Mobile Safari,Hyperlink,好吧,与其试着用文字解释我的问题,不如看我录制的这个小视频 下面是详细视图控制器(webview所在的页面)的代码 detailViewController.h #import <UIKit/UIKit.h> #import "MWFeedItem.h" @interface DetailViewController : UIViewController <UIWebViewDelegate> { MWFeedItem *item; NSString

好吧,与其试着用文字解释我的问题,不如看我录制的这个小视频

下面是详细视图控制器(webview所在的页面)的代码

detailViewController.h

#import <UIKit/UIKit.h>
#import "MWFeedItem.h"
@interface DetailViewController : UIViewController <UIWebViewDelegate>  {
    MWFeedItem *item;
    NSString *summaryString;
    IBOutlet UILabel *titleLabel;
    IBOutlet UIWebView *contentLabel;
    //IBOutlet UILabel *dateLabel;
    IBOutlet UIScrollView *textScroller;
}
@property (nonatomic, retain) MWFeedItem *item;
@property (nonatomic, retain) NSString *summaryString;
@property (nonatomic, retain) IBOutlet UILabel *titleLabel;
@property (nonatomic, retain) IBOutlet UIWebView *contentLabel;
@end
注意:尽管上面写着“contentLabel”,但它是一个UIWebView。它是旧版本遗留下来的

谢谢

实现
-(BOOL)webView:(UIWebView*)webView应与请求一起加载:(NSURLRequest*)请求导航类型:(UIWebView导航类型)导航类型

然后您可以这样做:

NSURL* url = [request URL];
if (UIWebViewNavigationTypeLinkClicked == navigationType)
{
    [[UIApplication sharedApplication] openURL:url];
    return NO;
}

非常感谢。我唯一需要更改的是,在委托实现中,将第二个“webView”改为“contentLabel”(我的webView的名称),然后将“return YES;”放在您展示给我的代码的花括号外。非常感谢。
NSURL* url = [request URL];
if (UIWebViewNavigationTypeLinkClicked == navigationType)
{
    [[UIApplication sharedApplication] openURL:url];
    return NO;
}