Objective c 如何添加uibutton并将其放置在UITableView的底部?
新手问题 我以编程方式创建了一个uitable,需要在表的底部添加一个提交按钮,设置Objective c 如何添加uibutton并将其放置在UITableView的底部?,objective-c,uibutton,Objective C,Uibutton,新手问题 我以编程方式创建了一个uitable,需要在表的底部添加一个提交按钮,设置mybutton.frame=CGRectMake(xxxx)和我的表无关,知道吗?这是我的uitable代码 CGRect tableViewFrame = self.view.bounds; self.myTable = [[UITableView alloc] initWithFrame:tableViewFrame
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];
要将按钮放在tableView的底部,请尝试以下操作:
UIButton *submit = [UIButton buttonWithType:UIButtonTypeCustom];
[submit setFrame:CGRectMake(0, tableViewFrame.origin.y + tableViewFrame.size.height, 80, 80);
[[self view] addSubview:submit];
最简单的方法是将其设置为表的footerView。正常创建按钮,然后将其作为页脚视图添加到表中
UIButton * b = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[b setTitle:@"Submit" forState:UIControlStateNormal];
[b addTarget:self action:@selector(submitButtonClicked) forControlEvents:UIControlEventTouchUpInside];
self.myTable.tableFooterView = b;
然后,您只需要实现
submitButtonClick
函数,在单击按钮时执行您想要的任何操作。tks用于答复,但是,这实际上是我的问题isif i setFrame.CGRectMake对于任何超过500的高度,按钮将消失,看起来我的按钮的位置与uitableview无关,更像是CSS中的静态位置我的tableview的高度比屏幕长..我最终使用了-(UIView*)tableview:(uitableview*)tableview for FooterInstitution:(NSInteger)部分,但您的想法是灵感的来源。虽然我仍然不知道如何在viewDidLoad中直接设置按钮位置