我正在面临一些似乎无法理解的问题。
我有这段代码,在 Xcode 5 和 iOS 7 中可以完美地运行:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CGFloat width = self.view.frame.size.width;
CGFloat height = self.view.frame.size.height;
UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
NSString* embedHTML = @"\
<html><head><meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; user-scalable=0;\"/>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: black;\
}\
</style>\
</head><body style=\"margin:0;\">\
<embed id=\"yt\" src=\"https://www.youtube.com/v/M7lc1UVf-VE?hd=1\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, width, height];
[webview loadHTMLString:html baseURL:nil];
[self.view addSubview:webview];
}
当我在Xcode 6中为iOS 8构建相同的代码时,视频显示在webview中,但太小了。
有人可以解释一下这里发生了什么,以及我如何克服这个问题吗?