0
次のコードでYouTubeの動画をプリントして横に表示し、次の動画のためにスワイプします。私は各ビデオがリンクを共有できるようにしたい、私はこの目的のためにAddThisを加えた。NSStringを更新するには
ただし、動画リンクを動的に更新する方法(または動画ごとに新しいボタンを表示する方法)はわかりません。
UIWebView *aVideo;
int size = 0;
for (int i=0; i<[vidsID count]; i++) {
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 *videoLink = [@"http://youtube.com/watch?v=" stringByAppendingString:[vidsID objectAtIndex:i]];
NSString *html = [NSString stringWithFormat:embedHTML, [@"http://youtube.com/watch?v=" stringByAppendingString:[vidsID objectAtIndex:i]], 320.f, 242.f];
addThisButton = [AddThisSDK showAddThisButtonInView:self.view
withFrame:CGRectMake(10, 5, 70, 25)
forURL:videoLink
withTitle:@"Watch this video!"
description:@"Watch this video: "];
addThisButton.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
aVideo = [[UIWebView alloc] init];
aVideo.frame = CGRectMake(320*i, 45, 320, 242);
[aVideo loadHTMLString:html baseURL:nil];
[aVideo setBackgroundColor:[UIColor clearColor]];
[myScrollView addSubview:aVideo];
size = size+320;
[aVideo release];
}
だから; 'NSMutableString * videoLink = [@" http://youtube.com/watch?v= "appendString:[vidsID objectAtIndex:i]];'? –
これを試してください:NSMutableString * videoLink = [NSMutableString stringWithFormat:@ "http://youtube.com/watch?v=%@"、[vidsID objectAtIndex:i]]; – Peres