【发布时间】:2011-05-30 21:04:00
【问题描述】:
我已经使用 UIWebView 成功嵌入了 vimeo 视频。然而,因为我已经在代码中创建了这个,我必须调整代码中的定位,我更愿意通过界面生成器来完成。如果我错了,请纠正我,我读到使用 initWithCoder 方法初始化 UIWebView 是实现此目的的方法。但是我不确定如何正确使用这种方法,如果它完全正确的话。
这里有一段代码来展示我到目前为止所做的事情:
- (void) viewDidLoad{
[super viewDidLoad];
[self embedVimeo:@"http://player.vimeo.com/video/19969613" frame:CGRectMake(300, 100, 260, 200)];
[self embedVimeo:@"http://player.vimeo.com/video/19967404" frame:CGRectMake(100, 300, 260, 200)];}
- (void)embedVimeo:(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\">\
<iframe src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></iframe>\
</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];
[[[videoView subviews] lastObject] setScrollEnabled:NO];
[mainView addSubview:videoView];
[videoView release];
}
有什么想法吗?
托德
【问题讨论】:
标签: iphone ios ipad uiwebview interface-builder