1

如果我使用

 -(void)viewWillDisappear:(BOOL)animated
    {
        [subView loadHTMLString:nil baseURL:nil];
    }

我的 Webview 无法工作

I try to do this
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    pageControlBeingUsed = NO;

    [subView loadHTMLString:nil baseURL:nil];


}

我只想通过分页滚动视图进入下一页并在下一页停止视频

这是我的代码滚动视图分页

book = [[NSMutableArray alloc] initWithObjects:@"page11",@"page12",@"page13",@"page14",@"page15", nil];

for (int i = 0; i < [book count]; i++) {

    CGRect frame;
    frame.origin.x = self.scrollView.frame.size.height * i;
    frame.origin.y = 0;
    frame.size = CGSizeMake(1024,768);
    subView = [[UIWebView alloc] initWithFrame:frame];
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[book objectAtIndex:i] ofType:@"html" inDirectory:@""]];
    [subView loadRequest:[NSURLRequest requestWithURL:url]];
    subView.scalesPageToFit = YES;
     [scrollView setBounces:NO];
    [scrollView addSubview:subView];
}
scrollView.contentSize = CGSizeMake(1024 * [book count], 768);
[scrollView setFrame:CGRectMake(0, 0, 1024, 768)];

我可以播放视频并在下一页停止吗?//请指教

抱歉我的英语不好

4

2 回答 2

0

感谢您的建议。我试试这对我有用

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    pageControlBeingUsed = NO;
    CGFloat pageWidth = self.scrollView.frame.size.width;
    int page = floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;


    for(int i = 0; i < _pageAmount ; i++){

        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
        [_collectionView cellForItemAtIndexPath:indexPath].backgroundColor = [UIColor clearColor];
    }

    currentPage = page;

    if (currentPage > 0 && currentPage < [book count]-1) {
        [[self.scrollView.subviews objectAtIndex:currentPage-1]reload];//
        [[self.scrollView.subviews objectAtIndex:currentPage+1]reload];

    }

    if(self.interfaceOrientation == 1 || self.interfaceOrientation == 2){

        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:page inSection:0];
        [_collectionView cellForItemAtIndexPath:indexPath].backgroundColor = [UIColor redColor];

    }
}
于 2014-02-16T09:32:02.637 回答
0

您需要将空白页面加载到 UIWebView 以停止音频:

[self.webView loadRequest:NSURLRequestFromString(@"about:blank")];

或者

[self.webView  loadHTMLString:@"" baseURL:nil];
于 2013-10-01T11:23:46.480 回答