【发布时间】:2011-06-11 09:37:32
【问题描述】:
我的应用程序中有一个脚本,它在 UIView 的一部分中加载一个 Youtube 链接,该链接由我的服务器(mySQL/使用 php)提供,并从中加载......下面的这个脚本工作正常。 ....然而...
这就是我现在所拥有的,我正在寻找以编程方式删除它的部分(它提供尺寸并可能用 UIWebView 替换它),所以我可以使用 IB 即兴创作,这将在我的应用程序启动时有所帮助,会出现一个快速动画,然后我希望这个 youtube 链接在 viewDidLoad 完成后加载和显示。
.h 文件:
- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame;
.m 文件
//view did load function...
[self embedYouTube:youtubestring frame:CGRectMake(69,72,184,138)];
//after the view did load is closed I have..
- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:html baseURL:nil];
[self.view addSubview:videoView];
[videoView release];
}
任何帮助将不胜感激!谢谢
【问题讨论】:
标签: iphone sdk uiwebview youtube