2016-12-15 24 views

回答

1

你有兩個選擇,如果你想要一個簡單的解決方案:

1.用按鈕,創建一個頁腳視圖,然後這個頁腳添加到您的使用表格視圖的方法:

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? 

func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat 

該解決方案將使您的滾動按鈕與表視圖

2.使用UIViewController而不是UITableViewController

  • 在故事板添加的UITableView到您的視圖控制器
  • 爲UITableView的創建一個IBOutlet - 連接它
  • 使您的視圖控制器符合UITableViewDelegateUITableViewDataSource
  • se牛逼tableView.delegate = selftableView.dataSource = self
  • 在故事板上添加一個按鈕以下表格視圖
  • 的按鈕,創建IBOutlet中,並將其連接

使用此解決方案,您的按鈕,將永遠留在屏幕上,只有表視圖會滾動

2

你可以試試這個。

let bottomButton = UIButton(frame: CGRect(x: 100, y: 300, width: 100, height: 30)) 
bottomButton.setTitle("Enter Text Here", for: .normal) 
bottomButton.backgroundColor = UIColor.orange 
view.addSubview(bottomButton) 

您可以根據您的視圖控制器設置x,y位置。另外,根據tableViewController的寬度和高度設置寬度和高度。

+0

不錯的解決方案@Priya Arora – Harish

相關問題