开发者

How to put a UIView in a UITableView

开发者 https://www.devze.com 2023-02-02 04:40 出处:网络
I have a UITableView and I\'m trying to put a graph in my table above the cells. I have a \"GraphView\" that I\'ve made that extends UIV开发者_Python百科iew and I\'d like to put it in my table. How ca

I have a UITableView and I'm trying to put a graph in my table above the cells. I have a "GraphView" that I've made that extends UIV开发者_Python百科iew and I'd like to put it in my table. How can I do this?


You could set it as the tableHeaderView, like so:

UITableView *tv = ...;

tv.tableHeaderView = yourView;

or using Interface Builder, even easier.

Read the documentation of UITableViewDataSource and UITableViewDelegate to find out more about these functions:

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

You should then return a UIView per section. (remember to autorelease them, if they are not statically allocated!)

0

精彩评论

暂无评论...
验证码 换一张
取 消