Embed Youtube Video using iFrame JS Player API

Here's the code to embed Youtube video using their new iFrame Javascript Player API. This is the piece of code I also used to embed YouTube video in my iOS application. Also, it is possible to play it inline. Not the typical fullscreen playback.

Read more about the iFrame Player API Reference.

It's also worth mentioning that on iOS6 devices, autoplay just doesn't work anymore. Apple added this restriction to save user's bandwidth. Read more about User Control of Downloads Over Cellular Networks.

UPDATE 2014-10-29
- Use this instead: https://developers.google.com/youtube/v3/guides/ios_youtube_helper

iOS: Stopping a chain of Block-based animations

This can easily be done using one line of code and given you're using either [UIView animateWithDuration:animations:] or [UIView animateWithDuration:animations:completion], or both of them interchangeably.

[someView.layer removeAllAnimations]

But what if another variant of these methods is also in the mix? This method is [UIVIew animateWithDuration:delay:options:animations:completion].

What happens is that, whatever is in the completion block of this method, it still is executed right after calling [CALayer removeAllAnimations]. So the right thing to do here is always check for the value of the Boolean argument, finished. If it evaluates to True, then let the rest of the code continue. Otherwise, stop. Also, make sure to include UIViewAnimationOptionAllowUserInteraction in the options parameter.

iOS: Unrecognized selector sent to class...

There are several reasons why this could happen. One of this is when adding a static Objective-C Library into your project. While compiling the app may seem to work fine, the actual code using the library may encounter this exception. The simple solution to this is to add a linker flag -all_load to your project's Targets->YourProject->Build Settings->Linking->Other Linker Flags

Read Apple's technical note about this issue here.

IMPORTANT: For 64-bit and iPhone OS applications, there is a linker bug that prevents -ObjC from loading objects files from static libraries that contain only categories and no classes. The workaround is to use the -all_load or -force_load flags. -all_load forces the linker to load all object files from every archive it sees, even those without Objective-C code. -force_load is available in Xcode 3.2 and later. It allows finer grain control of archive loading. Each -force_load option must be followed by a path to an archive, and every object file in that archive will be loaded.