2
처음로드 한 후 Safari에서 URL을로드하려고합니다. 다른 웹 페이지로,이 코드는 잘 작동 :UIWebView가 아닌 Safari에서 YouTube URL을 엽니 다.
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL* url = [request URL];
if (UIWebViewNavigationTypeLinkClicked == navigationType)
{
[[UIApplication sharedApplication] openURL:url];
return NO;
}
return YES;
}
하지만 최대한 빨리 m.youtube.com으로 향하기로, 코드가 더 이상 아무것도하지, 유튜브가있는 UIWebView 내부에로드하고 있습니다. 이 온라인에 대해서는 아무 것도 찾을 수 없습니다. 어떤 도움이 필요합니까? 여기
내 전체하는 .m 파일입니다#import "SecondViewController.h"
@interface SecondViewController()
@end
@implementation SecondViewController
@synthesize topLayer = _topLayer;
@synthesize layerPosition = _layerPosition;
@synthesize webView = webView;
#define VIEW_HIDDEN 260
- (void)viewDidLoad
{
[super viewDidLoad];
webView.delegate = self;
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.youtube.com"]]];
[webView setBackgroundColor:[UIColor clearColor]];
[webView setOpaque:NO];
webView.scrollView.bounces = NO;
webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
[self performSelector:@selector(makeTick)];
self->promoteImages.contentSize = CGSizeMake(1920, 101);
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Scroll3.png"]];
[self->promoteImages addSubview:imageView];
[promoteImages setShowsHorizontalScrollIndicator:NO];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
}
return YES;
}
@end
그리고 여기보기 컨트롤러 내 .H 파일입니다 :
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
}
return YES;
}
: 여기
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <Social/Social.h>
@interface SecondViewController : UIViewController <UIWebViewDelegate>
{
IBOutlet UIScrollView *promoteImages;
NSTimer *time;
IBOutlet UIWebView *webView;
}
@property (nonatomic, nonatomic) UIWebView *webView;
@property (weak, nonatomic) IBOutlet UIView *topLayer;
@property (nonatomic) CGFloat layerPosition;
@property(nonatomic,readonly,getter=isDragging) BOOL dragging;
@end
이 정확히 같은 일을 - 링크를 클릭하면 Safari에서 YouTube를 제외한 모든 웹 사이트가 열립니다. – Stickerbox
YouTube 링크가 YouTube 앱 내부로로드된다고 하시겠습니까? 또는 앱 내의 webView 내부에 있습니까? – adamdehaven
webView 내부로로드됩니다. – Stickerbox