UIButton underneath grouped table view

纵饮孤独 提交于 2020-01-01 06:54:13

问题


Basically, I want to create a button underneath a grouped table view, like contacts.app has to delete contacts.

I can create the button fine, I'm just a bit puzzled as to how to decide where to put it.

I thought I could just do:

CGRect bounds = [[self tableView] bounds];

Then place the button based on that.

However, when accessing the size.height of bounds I get zero! Is there a dynamic way to retrieve the tableView's height that I could be missing?

Any help is greatly appreciated.

Rich


回答1:


You can create the size of your button like

CGRect buttonFrame = CGRectMake(0, 0, width, height);

Create the button with that frame, and then set the button as the tableView's footer

myTableView.tableFooterView = myButton;



回答2:


You could try making a custom footer view with those buttons placed in that view by implementing these methods:

- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

That should let you put any number of buttons on your table underneath the section you want.




回答3:


You can get the tablewViews heigh by looking at its frame

CGRect bounds= [[self tableView] frame]; 
float heigh= frame.size.height;


来源:https://stackoverflow.com/questions/1456668/uibutton-underneath-grouped-table-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!