iOS dynamically alters the height of the UITableView tableviewheader

Source: Internet
Author: User

The development of these days, there is a need to dynamically change the Tableviewheader interface, was directly in the viewdidload inside set a bit of tableviewheader=viewheader; Now assume that ViewHeader is the TableView head view)
Then after the data from the server, dynamically set the height of the viewheader, found that there is no effect ...

So let's briefly analyze:
ViewHeader as a tableview tableheaderview, simple to change the viewheader frame is useless, tableview will not be generous to the time to adapt to its height (after Apple will not change will not know), so , how to tell TableView its tableheaderview has changed. Very simple, just one word (key last sentence):

[WebView SizeToFit];
CGRect newframe = viewheader.frame;
NewFrame.size.height = NewFrame.size.height + webView.frame.size.height;
Viewheader.frame = Newframe;
[Self.tableview Settableheaderview:viewheader];

After that, the effect will come out. But this excessive appears some blunt, can add a little animation, let it become pleasing to some. Try the following code:

[Self.tableview beginupdates];
[Self.tableview Settableheaderview:viewheader];
[Self.tableview endupdates];

PS: Do you like my Jane book article, like, click on the attention bar .... Share a little bit of development

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.