Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom View with dynamic Height as UITableView Header ios xcode

In my project,i have a 1.MovieplayerView,2.a label with dynamic content,3.a tableView with variable number of rows.

I was doing this with all these views in scrollView.But i always have the issue with dynamic height of the label.it sometime overlaps the tableView.

I came to know that we can use customView as the tableView header.How this can be done with variable content Height and autolayout?I am new to iOS.Any suggestion ??

I know how to add a view as the header to a table.But when the contents in the view changes,it overlaps the contents of the tableView.

I went through How to resize superview to fit all subviews with autolayout?,How do I set the height of tableHeaderView (UITableView) with autolayout?

Can some one give a simple example on how to do this?Or tell me if it is better to use a scrollview and add all these views as its subviews? any suggestion would be realy helpful.Thanks.

like image 235
abhimuralidharan Avatar asked May 15 '26 19:05

abhimuralidharan


1 Answers

In viewDidAppear,
1. Get the height of the dynamic content, then set the height of your tableHeaderView accordingly. 2. Set the headerView again so the table view can refresh: self.tableView.tableHeaderView = headerView

like image 130
cooltch Avatar answered May 17 '26 08:05

cooltch