0

新手问题,

我以编程方式创建了一个 uitable,需要在表格底部添加一个提交按钮,设置mybutton.frame = CGRectMake(xxxx)与我的表格无关,知道吗?这是我的 uitable 代码

CGRect tableViewFrame = self.view.bounds;

self.myTable = [[UITableView alloc] initWithFrame:tableViewFrame
                                            style:UITableViewStyleGrouped];

self.myTable.autoresizingMask = UIViewAutoresizingFlexibleWidth |  
                                UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.myTable];
4

2 回答 2

0

要将按钮放在 tableView 的底部,请尝试以下操作:

UIButton *submit = [UIButton buttonWithType:UIButtonTypeCustom];
[submit setFrame:CGRectMake(0, tableViewFrame.origin.y + tableViewFrame.size.height, 80, 80);
[[self view] addSubview:submit];
于 2013-09-06T17:07:50.230 回答
0

最简单的方法是将其设置为表格的 footerView。正常创建按钮,然后将其作为页脚视图添加到表格中

UIButton * b = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[b setTitle:@"Submit" forState:UIControlStateNormal];
[b addTarget:self action:@selector(submitButtonClicked) forControlEvents:UIControlEventTouchUpInside];

self.myTable.tableFooterView = b;

然后,您只需要实现该submitButtonClicked功能即可在单击按钮时执行您想做的任何事情。

于 2013-09-06T17:24:18.737 回答