Calculate UIWebView height depending on its content

后端 未结 2 1725
栀梦
栀梦 2020-12-14 13:39

I have a class named Announcement, it has a Title (NSString), a Publishing Date (NSString) and a Body<

2条回答
  •  忘掉有多难
    2020-12-14 14:24

    There are a few ways of finding the height of a UIWebView's content.

    Here are a few pointers to start with:

    How to determine UIWebView height based on content, within a variable height UITableView?

    How to determine the content size of a UIWebView?

    iPhone - get the Content Size of UIWebView

    Note that using a UIWebView in a UITableView isn't necessarily a very good idea, specially if you have many Announcements to scroll through in the same UITableView. If you show only one Announcement per UITableView, you should be able to get away with it, but for tables with a lot of cells to scroll through, using webviews in the cells can lead to bad performance issues.

    Apple also recommend against using embedding UIWebViews / UITableViews / UIScrollViews.

    From the UIWebView Class Reference :

    Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

    My 2 cents :)

提交回复
热议问题