The next code only works if LBYouTubePlayerController* controller;
is inside @implementation ViewController
. Can someone explain to me why I get this behavior and what's the difference ?
.h file:
#import <UIKit/UIKit.h>
#import "LBYouTube.h"
@interface ViewController : UIViewController<LBYouTubePlayerControllerDelegate>
@end
.m file:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
{
LBYouTubePlayerController* controller;
}
- (void)viewDidLoad
{
[super viewDidLoad];
controller = [[LBYouTubePlayerController alloc] initWithYouTubeURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=1UlbCgB9vms"] quality:LBYouTubeVideoQualityLarge];
controller.delegate = self;
controller.view.frame = CGRectMake(0.0f, 0.0f, 200.0f, 200.0f);
controller.view.center = self.view.center;
[self.view addSubview:controller.view];
If i'll move LBYouTubePlayerController* controller;
and put it inside viewDidLoad
the video won't load:
- (void)viewDidLoad
{
LBYouTubePlayerController* controller = [[LBYouTubePlayerController alloc] initWithYouTubeURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=1UlbCgB9vms"] quality:LBYouTubeVideoQualityLarge];
controller.delegate = self; ....}