Disable rubber-band scrolling for webview in lion

落爺英雄遲暮 提交于 2019-12-18 02:50:33

问题


I have a Cocoa webview, with a web application in it. The web application has a fixed toolbar itself, and with the elastic scrolling, and the toolbar coming below the top, it looks bad. Is there a way to disable the elastic/rubber-band scrolling, or at least keep the toolbar from moving with the rest of the content? I can modify the web app as much as neede.


回答1:


Maybe this article would help you.

In short: disable overflow on HTML and BODY, add a wrapper with overflow:auto around all the page contents




回答2:


If you're interested in doing it from the WebView and Cocoa perspective, you can also implement the finish load delegate, grab the scroll view, and disable elasticity:

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
    NSScrollView *mainScrollView = sender.mainFrame.frameView.documentView.enclosingScrollView;
    [mainScrollView setVerticalScrollElasticity:NSScrollElasticityNone]; 
    [mainScrollView setHorizontalScrollElasticity:NSScrollElasticityNone];
}



回答3:


I know this comment likely won't be accepted, since there's already an answer.

However, there's an actual method you can call on your NSView (docs here):

[[[webView mainFrame] frameView] setAllowsScrolling:NO]; 


来源:https://stackoverflow.com/questions/7020842/disable-rubber-band-scrolling-for-webview-in-lion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!