Its the first time that I use UIWebView and the first time that I use video in iPhone. The video plays, BUT:
I want to have an old school tv (round corners) in foreground with switches and so on. The tv is an image with transparent pixels in the middle, so that a video lying behind the tv will shine through as if the video would be shown on the tv.
But first of all the video has a border that I can't remove and second it's always in the foreground. In Safari and in Firefox on Mac it's working. So is it an iPhone thing, could it be that it simply won't work on iPh开发者_开发技巧one ? Or do I have some css/html typos ?
I'm using this code:
- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
NSString *embedHTML = @"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: black;\
}\
#container{\
position: relative;\
z-index:1;\
}\
#video,#videoc{\
position:absolute;\
z-index: 1;\
border: none;\
}\
#tv{\
background: transparent url(tv.png) no-repeat;\
width: 320px;\
height: 205px;\
position: absolute;\
top: 0;\
z-index: 999;\
}\
</style>\
</head><body style=\"margin:0\">\
<div id=\"tv\"></div>\
<object id=\"videoc\" width=\"240\" height=\"160\">\
<param name=\"movie\" value=\"%@\"></param>\
<param name=\"wmode\" value=\"transparent\"></param>\
<embed wmode=\"transparent\" id=\"video\" src=\"%@\" type=\"application/x-shockwave-flash\" \
width=\"240\" height=\"160\"></embed>\
</object>\
</body></html>";
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString *html = [NSString stringWithFormat:embedHTML, urlString,urlString];
UIWebView *videoView = [[UIWebView alloc] initWithFrame:frame];
[videoView loadHTMLString:html baseURL:baseURL];
[self.view addSubview:videoView];
[videoView release];
}
I have not found a css/html/js solution.
So now I add the TV.png to a UIImageView and lay that view on top of the UIWebView, it's working and not that big of a hack, so I will go with it, but maybe someone can still answer the original question ?
So my current layer order is now:
UIView
add: UIWebView
add: UIImageView (with UIImage TV.png)
精彩评论