UIWebView无法滚动到底部

3

我是一个新手iPad开发者,

我正在为我的应用程序制作ePub阅读器,在其中我使用UIWebView加载我的ePub页面

当我在webview中加载页面时,它只能滚动到一定的限制,

这是我的代码片段,

- (void)viewDidLoad {
...

    _webview=[[UIWebView alloc]init];
    _webview.frame=CGRectMake(0, 0, 770, 960);
    [_webview setBackgroundColor:[UIColor grayColor]];
    _webview.delegate=self;
    [self.view addSubview:_webview];

    [self loadPage];
...
}



 - (void)loadPage{

  [_webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]];

    [self._webview sizeToFit];
    _webview.scalesPageToFit=TRUE;
    _webview.scrollView.bounces = NO;
    _webview.autoresizesSubviews = YES;

}

1
请尝试使用语言规范。你的代码几乎无法阅读。 - dasdom
3个回答

5

删除所有行并只写这些行:

_webview.scalesPageToFit=TRUE;
_webview.scrollView.bounces = NO;

3
如果您使用 UIWebView 无法正确滚动到底部:
1)一种解决方法(通过编程实现)是使用适当的自动调整大小来解决 UIWebView 的问题。
self.webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin ;

enter image description here

2) 另一种解决问题的方式(接口生成器)是使用适当的自动调整大小来处理 UIWebView。转到接口生成器->Web View->Size Inspector 并在所有位置上勾选自动调整大小部分(如上图所示)。


0

1) 尝试隐藏NavigationBar

self.navigationController.hidesBarsOnSwipe = YES;

2) 尝试使 WebViewScale 适应 View

webView.scalesPageToFit=YES;
webView.scrollView.bounces = NO;

3)或者可能是WebView的框架问题,请尝试

UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-self.navigationController.navigationBar.frame.size.height)];

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接