UITextView внутри PrototypeCell ведут себя по-разному в двух симуляторах iPhone - PullRequest
0 голосов
/ 18 октября 2018

У меня есть UITableView с двумя ячейками для ввода информации пользователем.

Первая ячейка: две кнопки «Отмена» и «Готово».Вторая ячейка: A UITextView для информации о типе пользователя.

Это отлично работает в iPhone 7, 6s ... но в iPhone SE и 5C экран отличается.Я использовал авто-макет и в раскадровке кажется работает отлично.Подробно: мне нужно было установить Height Constraint в TextView для работы.

Разницу можно увидеть на изображении ниже:

enter image description here

Раскадровка:

enter image description here

Ограничения TableView:

enter image description here

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!
}

1 Ответ

0 голосов
/ 18 октября 2018

Главное ограничение TableView для безопасной зоны вызывает проблемы.Добавьте следующие ограничения:

  1. По горизонтали и вертикали от центра к суперпредставлению.
  2. Фиксирование высоты и Фиксирование ширины / Ведущий и тянущийся к Суперпредставлению.

Надеюсь, что так и будетработает для вас.

enter image description here

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...