滚动视图中的问题
我有一个 UIScrollView,需要在其中添加两个视频,但我面临以下问题:
*我有一个有两个页面的滚动视图。如果我只在第一个视频中添加一个,它就可以正常工作。在第一页中我将拥有视频,第二个将是空的。
*如果我尝试添加两个视频 - 滚动视图的第一页将为空,第二页将包含第二个视频。
无论我如何行动,我都无法在滚动视图中同时显示两个视频。
这就是我所做的:
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];
请帮忙。谢谢
I have a UIScrollView in which I need to add two videos, but I'm facing the following issue:
*I have a scrollView with two pages.If I add only one the first video, it works ok.In the first page of the scrollView I'll have the video and the second one will be empty.
*If I try to add both videos-the first page of the scrollView it will be empty and the scond one will contain the second video.
No matter how I act I cannot have both videos in the scrollView.
Here is what I did:
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];
Please help.thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论