scrollView中的问题

时间:2011-10-18 13:43:48

标签: iphone mpmovieplayercontroller

我有一个UIScrollView,我需要在其中添加两个视频,但我面临以下问题:

*我有一个带有两个页面的scrollView。如果我只添加一个第一个视频,它就可以正常工作。在scrollView的第一页,我将有视频,第二个将是空的。

*如果我尝试添加两个视频 - scrollView的第一页将为空,第二页将包含第二个视频。

无论我如何行动,我都无法在scrollView中同时拥有这两个视频。

这是我做的:

 scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];


scrollView.pagingEnabled = YES;

NSString *path1 = [[NSBundle mainBundle] pathForResource:@"video1" ofType:@"mp4"];
NSString *path2 = [[NSBundle mainBundle] pathForResource:@"video2" ofType:@"mp4"];

videoPlayer1 = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path1]];
videoPlayer2 = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path2]];

[[videoPlayer1 view] setFrame:CGRectMake(0, 0, 320, 335)];
[videoPlayer1 prepareToPlay];


[videoPlayer1 setControlStyle:MPMovieControlStyleDefault];
videoPlayer1.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[self.scrollView addSubview:[videoPlayer1 view]];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:videoPlayer1];

[[videoPlayer2 view] setFrame:CGRectMake(320, 0, 320, 335)];
[videoPlayer2 prepareToPlay];

[videoPlayer2 setControlStyle:MPMovieControlStyleDefault];
videoPlayer2.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[self.scrollView addSubview:[videoPlayer2 view]];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:
 MPMoviePlayerPlaybackDidFinishNotification object:videoPlayer2];

scrollView.contentSize = CGSizeMake(640, 400);
[self.view addSubview:scrollView];

请帮忙。谢谢你

0 个答案:

没有答案