У меня есть табличное представление, и внутри него я добавил ячейку с меткой справа от вида.
Вот как выглядит моя ячейка: ![enter image description here](https://i.stack.imgur.com/Qvn5Z.png)
Но когда я запускаю приложение, это то, что я получаю.(Он запускается на iPhone 6S):
![enter image description here](https://i.stack.imgur.com/nBQHz.png)
Как видите, ярлык выталкивается.
Результат на iPhone XR в порядке.Вот снимок экрана для XR: ![enter image description here](https://i.stack.imgur.com/3KRUm.png)
Вот код для контроллера представления, где делегаты представления таблицы:
import UIKit
class TableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .none
let headerViewNibName = UINib(nibName: "HeaderCell", bundle: nil)
tableView.register(headerViewNibName, forCellReuseIdentifier: "headerCell")
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "headerCell", for: indexPath) as! HeaderCell
cell.isUserInteractionEnabled = false
return cell
}
return UITableViewCell()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0 {
return 138
}
return 0
}
}
Может кто-нибудь объяснить, пожалуйстапочему это происходит?
Редактировать:
Прикрепить снимок экрана для вида ячейки с видимыми ограничениями: ![enter image description here](https://i.stack.imgur.com/9ffET.png)