UIWebView inside a UITableViewCell

六月ゝ 毕业季﹏ 提交于 2020-01-01 07:12:49

问题


Has anyone tried it? The hardest part for me is to get the height of the UITableViewCell to be the same as that of the UIWebView. By debugging into the code, I noticed that the delegate for UITableViewCell (heightForRowAtIndexPath for getting the height of the cell) is called before the one (webViewDidFinishLoad) for UIWebView is called. Any solution to work around that?

Super thanks!


回答1:


I saw this scenario demonstrated once on the iTunesU Stanford iPhone Application Development course. It's shown at the end of lecture 16, from the Spring 2009 sessions

This similar question on SO suggests laying out cells before heightForRowAtIndexPath exits. It would hurt performance for sure, but you could block within that method until the UIWebView is finished loading. Basically loop until the loading property is NO, then return the height of the UIWebView after it is finished.

If you're loading content from the Internet, this might bring your app to a screeching halt, though. If there's any way you can determine the height beforehand, you're better off doing that for performance reasons.



来源:https://stackoverflow.com/questions/2814994/uiwebview-inside-a-uitableviewcell

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