【发布时间】:2011-08-03 04:47:35
【问题描述】:
我想创建几个 CSS 来管理 UIWebView 中嵌入式视频播放器的方向。这些 CSS 将根据设备的方向调整播放器的大小。
如何在我的 iphone 应用程序中创建和添加 CSS 以在我的 iPhone/iPad 上执行以下代码?
<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css">
<link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css">
编辑:
以下是我为嵌入视频所做的代码。(*youTubePlayer 是 UIWebView 的一个实例。)
NSString* embedHTML = @"<html><head><style=\"margin:0\" link rel=\"stylesheet\" media=\"all and (orientation:portrait)\" href=\"portrait.css\">"
"<link rel=\"stylesheet\" media=\"all and (orientation:landscape)\" href=\"landscape.css\">"
"</style></head>"
"<body embed id=\"yt\" src=\"%@\"type=\"application/x-shockwave-flash\"></embed>"
"</body></html>";
NSString* html = [NSString stringWithFormat:embedHTML, url];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[youTubePlayer loadHTMLString:html baseURL:baseURL];
并且还添加了 landscape.css 身体 { 宽度:1002; 身高:768; }
portrait.css 身体 { 宽度:768; 身高:1024; }
即使它不能正常工作。代码有什么问题,请告诉我。
【问题讨论】: