小编ayv*_*yve的帖子

嵌入YouTube视频

我通过互联网上找到的代码片段从YouTube嵌入了一段视频,这是我用过的代码:

    @interface FirstViewController (Private)
- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame;
@end


@implementation FirstViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self embedYouTube:@"http://www.youtube.com/watch?v=l3Iwh5hqbyE" frame:CGRectMake(20, 20, 100, 100)];
}


- (void)embedYouTube:(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\">\
    <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
    width=\"%0.0f\" height=\"%0.0f\"></embed>\
    </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];
    [self.view addSubview:videoView];
    [videoView release];
}


- (void)didReceiveMemoryWarning {
    // Releases …
Run Code Online (Sandbox Code Playgroud)

youtube iphone objective-c ios

28
推荐指数
3
解决办法
3万
查看次数

如何使用UITextView在Objective-C中为iPhone保存/加载文本文件?

如何将文本文件永久保存到iPhone?然后能够在另一个UITextView中再次打开它们?

提前致谢.

iphone objective-c uitextview

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

iphone ×2

objective-c ×2

ios ×1

uitextview ×1

youtube ×1