0

enter image description hereI'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

How to get a tableview button like this

vignesh
  • 9
  • 4

1 Answers1

1

You need to separate the tableview and the button.

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.

Kenan Karakecili
  • 731
  • 6
  • 23
  • if i scroll tableview button also scroll from top to bottom.i want to set that button constant when i scroll tableview – vignesh Aug 01 '16 at 09:22
  • Okay then you better separate the tableview and the button. Place your button under the tableview and it will stay there while you're scrolling. There is no other way around. – Kenan Karakecili Aug 01 '16 at 09:45
  • I updated the answer. You can also download the sample project here: https://www.dropbox.com/s/lju3fsth15s6zm7/werwer.zip?dl=0 – Kenan Karakecili Aug 01 '16 at 11:49
  • its working sir..in that how to get checkmark in selected uitableview cell – vignesh Aug 03 '16 at 07:21
  • You can find that here: http://stackoverflow.com/questions/2797165/uitableviewcell-checkmark-change-on-select – Kenan Karakecili Aug 03 '16 at 08:02