我在以下代码中打印YouTube视频并水平显示它们,滑动查看下一个视频。我希望每个视频都能分享链接,为此我添加了AddThis。
但是,我不知道如何动态地更新视频链接(或者为每个视频显示一个新的按钮)。
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。这就是为什么你不能改变NSString的值。