调整QTMovieView的大小不起作用

时间:2011-07-05 10:36:10

标签: cocoa macos

我想在本地加载电影,这里是代码:

movie = [[QTMovie alloc]initWithFile:[[NSBundle mainBundle]pathForResource:@"movie" ofType:@"m4v"] error:nil];

movieView = [[QTMovieView alloc]initWithFrame:NSMakeRect(0, 0, 861, 646)];
[movieView setDelegate:self];

[movieView setMovie:movie];

[movie play];
[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(moviePlaybackDidFinished:) 
                                             name:QTMovieDidEndNotification 
                                           object:movie];

[movieView setControllerVisible:NO];

[movieView setAutoresizesSubviews:YES];
[movieView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[self.window setContentView:movieView];

movie.m4v的宽度为1024,高度为768,我希望保持窗口的大小(1024,768)。我想调整movieView 861x646的大小。但是当在窗口上显示时,它仍然是1024x768大小。

如何将电影尺寸调整为861x646尺寸?

1 个答案:

答案 0 :(得分:0)

您将电影视图设置为窗口的内容视图,因此它将自动成为窗口的内容大小并保持这种状态。您似乎想要做的是将您的视图添加到窗口的内容视图中。

[[[self window] contentView] addSubview:movieView];