次のコードは、LBYouTubePlayerController* controller;
が 内に ある場合にのみ機能し@implementation ViewController
ます。なぜ私がこの振る舞いをするのか、そして何が違うのか誰かが私に説明できますか?
.h ファイル:
#import <UIKit/UIKit.h>
#import "LBYouTube.h"
@interface ViewController : UIViewController<LBYouTubePlayerControllerDelegate>
@end
.m ファイル:
#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];
移動LBYouTubePlayerController* controller;
してビデオ内に配置するとviewDidLoad
、ロードされません:
- (void)viewDidLoad
{
LBYouTubePlayerController* controller = [[LBYouTubePlayerController alloc] initWithYouTubeURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=1UlbCgB9vms"] quality:LBYouTubeVideoQualityLarge];
controller.delegate = self; ....}