2016-08-01 54 views
0

enter image description here我有定制的tableview细胞的底部设置一个总按钮,我想在的tableview的可点击的我有自定义的tableview细胞和我在的tableview

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]; 
底部设置一个整体的按钮

如果我滚动tableview中按钮也从顶部滚动bottom.i要设置按钮时不断滚动的tableview

如何获得这样

+1

为什么你不使用故事板它更容易 –

+0

你有没有尝试过把它添加为表格页脚? https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/index.html#//apple_ref/occ/instp/UITableView/tableFooterView – Losiowaty

+0

试试这个[self.tableview addSubview:yourBtn]; – MuraliMohan

回答

1

你需要一个SEP按钮的tableview愤慨tableviewbutton

下面是代码:

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]; 

希望以上信息对您有帮助。

+0

如果我滚动tableview按钮也滚动从上到bottom.i想设置该按钮常数当我滚动tableview – vignesh

+0

好吧那么你最好分开桌面视图和按钮。将你的按钮放在tableview下面,当你滚动的时候它会停留在那里。没有其他办法。 –

+0

(http://i.stack.imgur.com/tDROD.jpg)如何获取像这样的uitableview按钮 – vignesh