UIWebView: how to hide part of the content of a webpage?

可紊 提交于 2019-12-11 08:45:38

问题


In my app I have a webview that is used solely for displaying the facebook page. However, the client does not want the top blue bar of facebook to appear; he wants to hide it. Is there a way to do this? The bar is 45 pixels, so what I did is I moved the UIWebView in IB in such a way that its top 45 pixels are behind my navigation bar (thus not appearing). However, this is not an ideal solution, as the user can see that content when he scrolls up, before bouncing. He can see but not touch it, which will be frustrating for some users. I tried turning the bouncing off, but then the UI becomes too rigid, and not fluid. I looked up in Google and Stackoverflow for a couple of hours but didn`t find a solution.

Thanks a lot!


回答1:


You'll have to edit the HTML/CSS of the page itself to hide the HTML elements in question, probably using regular expressions, and feed it into your UIWebView with loadHTMLString:baseURL:.

I've done similar manipulating before and it works, but... it's a different ballgame when the webpages in question don't belong to you. Any time Facebook updates their layout, your app behavior might change until you have time to get an app update approved. Clients want what they want, but make sure your client knows what he's asking for!




回答2:


First test out the javascript code used to hide whatever elements in the webpage and then pass up to stringByEvaluatingJavaScriptFromString of UIWebView to run it.



来源:https://stackoverflow.com/questions/9491080/uiwebview-how-to-hide-part-of-the-content-of-a-webpage

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