我正在嘗試創建一個自定義 Tableview 單元格,但模擬器上只顯示了一個狹窄的水平條形單元格。
即使我將模擬器更改為更大的設備,也會發生這種情況。我已經檢查以確保插座已連接。
import UIKit
class EstimatedIncomeCell: UITableViewCell {
static let identifier = "EstimatedIncomeCell"
@IBOutlet weak var amountTextField: UITextField!
@IBAction func buttonClicked(_ sender: Any) {
}
從視圖控制器:
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource{
@IBOutlet weak var incomesTableView: UITableView!
var amountOfIncomes = 1
override func viewDidLoad() {
super.viewDidLoad()
self.incomesTableView.delegate = self
self.incomesTableView.dataSource = self
self.registerTableViewCell()
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = incomesTableView.dequeueReusableCell(withIdentifier: "EstimatedIncomeCell") as? EstimatedIncomeCell{
return cell
}
return UITableViewCell()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
private func registerTableViewCell(){
let incomeCell = UINib(nibName: "EstimatedIncomeCell", bundle: nil)
self.incomesTableView.register(incomeCell, forCellReuseIdentifier: "EstimatedIncomeCell")
}
}


因此,對于您的 TextField:
- 改變
Top Space to: Superview從-46_13 - 洗掉
Align Center Y to: Superview約束 - 添加底部約束
13
對于您的按鈕:
- 洗掉
Align Center Y to: Superview約束 - 洗掉
Top Space to: Superview約束
這應該讓你至少接近你想要的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/515115.html
標籤:IOS迅速合适的视图
上一篇:存盤有關類屬性的資訊
