How to set UIView to UITableView

I have a UITableView, and I'm trying to put a graph in my table above the cells. I have a “GraphView” that I made that extends UIView, and I would like to put it in my table. How can i do this?

+1
source share
1 answer

You can set it as tableHeaderView, for example:

UITableView *tv = ...;

tv.tableHeaderView = yourView;

or using Interface Builder, even easier.

Read the documentation UITableViewDataSourceand UITableViewDelegateto find out more about these features:

 -(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
 -(UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section

Then you should return UIViewfor the section. (remember autoreleasethem if they are not statically allocated!)

+1
source

Source: https://habr.com/ru/post/1783046/


All Articles