2016-08-01 86 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