I am new to IOS application development. I've added the code for embedding Youtube video in my app by using UIWebview and the embed code from the youtube. But when I run the application in my simulator, the webview is simply blank. I don't see any video thumbnail or anything else. I heard youtube videos will not run on IPhone simulators but this link ("http://www.youtube.com/embed/36db4r3MsgU")shows that the video is playing perfectly in simulator. kindly look into this link and suggest me a solution.
NSString *code = @"<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/36db4r3MsgU?feature=player_detailpage\" frameborder=\"0\" allowfullscreen></iframe>";
[[self video]loadHTMLString:code baseURL:nil];
Thanks, Abilash.G
In iOS 8 it started working differently and added padding to the WebView. I posted an answer to this question, this works with iOS 9 and Xcode 7 beautifully. The padding (-8px) may need to be adjusted based on your needs but in general it works amazingly.
All you need to do it give it the code from any YouTube video (the last characters in any YouTube video URL)
See post here.
And here is the code:
@danh answer does work, but it embeds youtube's mobile webpage with the youtube player, which takes a lot of space and it looks terrible. The best option is to follow the instructions in the Youtube Api Blog:
UPDATE: Since youtube now uses v3 of its api, here is a new link with the oficial instructions: https://developers.google.com/youtube/v3/guides/ios_youtube_helper