我試圖讓一個mp4電影在UICollectionViewCell中播放。我沒有運氣讓它顯示。所以,我的第一個問題是:這可能嗎?如果是這樣,我做錯了什麼?這是一個非ARC項目,我沒有使用任何XIBs或情節串連圖板...UICollectionViewCell中的MPMoviePlayerController
NSURL * theURL = nil;
NSBundle * bundle = [NSBundle mainBundle];
if (bundle)
{
NSString * thePath = [bundle pathForResource:@"intro" ofType:@"mp4"];
if (thePath)
{
theURL = [NSURL fileURLWithPath:thePath];
}
}
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: theURL];
[player prepareToPlay];
[player.view setFrame: self.contentView.bounds]; // player's frame must match parent's
[self.contentView addSubview: player.view];
[player play];
[player release];
將播放器放在@property中,並檢查它。播放後不要釋放它。 – iDev 2013-02-28 22:56:57