У меня есть UITableView
с двумя ячейками для ввода информации пользователем.
Первая ячейка: две кнопки «Отмена» и «Готово».Вторая ячейка: A UITextView
для информации о типе пользователя.
Это отлично работает в iPhone 7, 6s ... но в iPhone SE и 5C экран отличается.Я использовал авто-макет и в раскадровке кажется работает отлично.Подробно: мне нужно было установить Height Constraint
в TextView для работы.
Разницу можно увидеть на изображении ниже:
![enter image description here](https://i.stack.imgur.com/HYn3Q.png)
Раскадровка:
![enter image description here](https://i.stack.imgur.com/sC2w2.png)
Ограничения TableView:
![enter image description here](https://i.stack.imgur.com/emS9D.png)
ViewController:
class LiberarViewController : UIViewController, UITableViewDelegate, UITableViewDataSource, UITextViewDelegate {
@IBOutlet weak var tableViewForm: UITableView!
var callback : ((String)-> ())?
override func viewDidLoad() {
tableViewForm.dataSource = self
tableViewForm.delegate = self
// tableViewForm.tableFooterView = UIView()
}
@objc func cancelar(_ sender: Any) {
self.dismiss(animated: true, completion: {})
}
@objc func finalizar(_ sender: Any) {
self.dismiss(animated: true, completion: {})
}
func textViewDidEndEditing(_ textView: UITextView) {
print("End edigint: \(textView.text!)")
}
func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
if section == 1 {
return "Digite a justificativa: "
}
return nil
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0:
let cell = tableView.dequeueReusableCell(withIdentifier: "CellBotoesLiberar") as! CellBotoesLiberar
cell.selectionStyle = .none
cell.btCancelar.addTarget(self, action: #selector(cancelar), for: .touchUpInside)
cell.btFinalizar.addTarget(self, action: #selector(finalizar), for: .touchUpInside)
return cell
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "CellJustificativaLiberar") as! CellJustificativaLiberar
cell.txtViewJustificativa.delegate = self
return cell
default: return UITableViewCell()
}
}
}
class CellJustificativaLiberar : UITableViewCell {
@IBOutlet weak var txtViewJustificativa: UITextView!
}
class CellBotoesLiberar : UITableViewCell {
@IBOutlet weak var btFinalizar: UIButton!
@IBOutlet weak var btCancelar: UIButton!
}