简体   繁体   English

我有自定义表格视图单元格,并在表格视图的底部设置了一个整体按钮

[英]I'm having custom tableview cell and I set a overall button at a bottom of a tableview

enter image description here I'm having custom tableview cell and I want to set a overall button at a bottom of a tableview with clickable 在此处输入图片描述,我拥有自定义表格视图单元格,并且我想在表格视图的底部设置一个整体按钮,并点击

UIButton*yourBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[yourBtn setImage:[UIImage imageNamed:@"wishlist"] forState:UIControlStateNormal];
//[yourBtn setTitle:@"+" forState:UIControlStateNormal];
yourBtn.frame = CGRectMake(0, self.view.bounds.size.height -100, buttonwidth, buttonheight);
yourBtn.center = CGPointMake(self.view.center.x, self.view.bounds.size.height -100);
[yourBtn addTarget:self action:@selector(addButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:yourBtn];

if i scroll tableview button also scroll from top to bottom.i want to set that button constant when scroll tableview 如果我滚动tableview按钮也从上到下滚动。我想在滚动tableview时将该按钮设置为常数

How to get a tableview button like this 如何获得这样的tableview按钮

You need to separate the tableview and the button . 您需要将tableviewbutton分开。

Here is the code: 这是代码:

UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
tableView.dataSource = self;
tableView.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:tableView];
UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeCustom];
yourButton.frame = CGRectMake(CGRectGetWidth(self.view.frame) - 70,
                            CGRectGetHeight(self.view.frame) - 70,
                            50,
                            50);
[yourButton setImage:[UIImage imageNamed:@"Untitled-1"] forState:UIControlStateNormal];
[self.view addSubview:yourButton];

I hope the above information is helpful for you. 希望以上信息对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM