在Lion中禁用webview的橡皮筋滾動

[英]Disable rubber-band scrolling for webview in lion


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.

我有一個Cocoa webview,里面有一個Web應用程序。 Web應用程序本身具有固定的工具欄,並且彈性滾動和工具欄位於頂部下方,看起來很糟糕。有沒有辦法禁用彈性/橡皮筋滾動,或者至少讓工具欄不與其他內容一起移動?我可以像neede一樣修改網絡應用程序。

3 个解决方案

#1


4  

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

簡而言之:在HTML和BODY上禁用溢出,在所有頁面內容周圍添加一個overflow:auto包裝器

#2


24  

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:

如果您對從WebView和Cocoa角度進行操作感興趣,還可以實現完成加載委托,獲取滾動視圖以及禁用彈性:

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

#3


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):

但是,您可以在NSView上調用實際方法(此處為docs):

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

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/08/11/720dd7e3ff3f12f3ec09d27f21b0cdb0.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com