我有一個UITableView
自定義單元格,在這個表格中,一個視頻列表顯示10乘10從服務器使用分頁概念。當你點擊視頻列表,然後視頻開始在moviePlayerController中播放,但是當你點擊完成moviePlayerController的Button
時,你的視頻列表被刷新。 我想停止這個刷新,並希望看到UITableView
與以前播放視頻相同。UITableView在關閉後不記得它的滾動位置moviePlayerController
請參閱代碼:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
CurrentVideoIndex =indexPath;
NSDictionary *VideoUrlDic = [videoList objectAtIndex:indexPath.row];
NSString *VideoUrl = [VideoUrlDic objectForKey:@"playUrl"];
//NSLog(@"VideoUrl is ::%@",VideoUrl);
NSURL *fileURL = [NSURL URLWithString:VideoUrl];
moviePlayerController= [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
[[moviePlayerController moviePlayer] prepareToPlay];
//[[moviePlayerController moviePlayer] setUseApplicationAudioSession:NO];
[[moviePlayerController moviePlayer] setShouldAutoplay:YES];
//[[moviePlayerController moviePlayer] setControlStyle:2];
//[[moviePlayerController moviePlayer] setRepeatMode:MPMovieRepeatModeOne];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoPlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[self presentMoviePlayerViewControllerAnimated:moviePlayerController];
}
-(void)videoPlayBackDidFinish:(NSNotification*)notification {
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[moviePlayerController.moviePlayer stop];
moviePlayerController = nil;
[[NSNotificationCenter defaultCenter] removeObserver:moviePlayerController name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayerController.moviePlayer];
if (![[self modalViewController] isBeingDismissed])
{
[self dismissMoviePlayerViewControllerAnimated];
[moviePlayerController.view removeFromSuperview];
[self hideProgress];
}
// [self.tableView scrollToRowAtIndexPath:CurrentVideoIndex atScrollPosition:UITableViewScrollPositionTop animated:NO];
//loading=NO;
}
#pragma UIScroll View Method::
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
if (!loading) {
float endScrolling = scrollView.contentOffset.y + scrollView.frame.size.height;
if (endScrolling >= scrollView.contentSize.height)
{
[self performSelector:@selector(loadDataDelayed) withObject:nil afterDelay:2];
}
}
}
#pragma UserDefined Method:::
-(void)loadDataDelayed{
counter +=10;
NSString *count = [NSString stringWithFormat:@"%d",counter];
NSLog(@"count value after Scrolling is :::%@",count);
[self createConnection:count];
}
你有一個'viewWillAppear中:'方法? – Wain
在viewWillAppear我沒有做任何事 – user2621383
你剛剛創建了一個新帳戶來轉貼這個問題:http://stackoverflow.com/questions/17872990/how-to-stop-reload-tableview-after-dissmiss-mpmovieplayerviewcontroller?你應該剛剛更新了原來的問題。 – Wain