2013-01-20 2 views
1

그래서이 문제를 설정하는 데 약간의 어려움이 있습니다. 나는이 코드를 사용하고있다 : UIWebView open links in Safari하지만 작동시키지 못한다.Safari에서 UIWebView URL 열기

여기 내 .H 파일입니다 :

#import <UIKit/UIKit.h> 

@interface SecondViewController : UIViewController 
{ 

} 

@property (strong, nonatomic) IBOutlet UIWebView *webView; 

@end 

그리고 여기 내하는 .m 파일입니다 :

#import "SecondViewController.h" 

@interface SecondViewController() 

@end 

@implementation SecondViewController 
@synthesize webView = _webView; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http:m.youtube.com/user/haatfilms/uploads"]]]; 
    [_webView setBackgroundColor:[UIColor clearColor]]; 
    [_webView setOpaque:NO]; 
    _webView.scrollView.bounces = NO; 
    _webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; 
} 

-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType { 
    if (inType == UIWebViewNavigationTypeLinkClicked) { 
     [[UIApplication sharedApplication] openURL:[inRequest URL]]; 
     return NO; 
    } 

    return YES; 
} 

@end 

그리고 나는 내가있는 UIWebView 대리자를 연결 한 생각 :

webView Delegate

하지만 여전히 링크를 클릭하면 여전히 UIWebView에로드되고 S에는로드되지 않습니다. 아사리.

누군가가 왜 작동하지 않는지에 관해 밝힐 수 있습니까? 고마워요

+0

당신은 이미 내가 것을 언급이 http://stackoverflow.com/questions/2899699/uiwebview-open-links-in-safari – JOM

+0

을 확인 했 나는 그 질문에 사용했다. 조금만 가지고 놀았지만 YouTube에서 작동하지 않지만 다른 웹 사이트에서는 작동한다는 것을 알았습니다. – Stickerbox

+0

예, YouTube는 다른 방식으로 iOS에서 내부적으로 처리되는 것 같습니다. – JOM

답변

0

발견. 대신 내 웹보기 대리자를 연결하는 IB를 사용, 그냥 이렇게 :

[super viewDidLoad]; 

    webView.delegate = self; 
관련 문제