开发者

How to update NSString

I print YouTube videos in the following code and display them horizontally, swipe for next video. I'd like each video to be able to share the link, i added AddThis for this purpose.

However, I don't know how to update the video link dynamically (or display a new button for each video).

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];  

    addThis开发者_如何学编程Button = [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];
}


You should use NSMutableString. That's why you cant change the value of your NSString.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜