【发布时间】:2020-02-11 17:33:01
【问题描述】:
我正在尝试在表单中显示一个 TableView。这在 iPhone 上完全可以正常工作。但是,当我出于某种原因在 iPad 上对其进行测试时,视图比表单大。 这是我正在谈论的图像:
如您所见,文本在框架中并非全部可见。全文是“这没有完全显示”
这是它应该看起来的样子(忽略黑暗模式)
在 MainController() 中,我通过在 ViewDidLoad() 中显示了这个页面 IntroController()
let navController = UINavigationController(rootViewController: IntroController())
present(navController, animated: true, completion: nil)
在 IntroController() 中这是代码。
import UIKit
var tableview: UITableView!
class IntroController: UIViewController, UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: TableCell.reuseIdentifier()) as! TableCell
cell.label.text = "Amount"
cell.typeLabel.text = "THIS IS NOT SHOWING FULLY"
cell.selectionStyle = .none
cell.accessoryType = .none
return cell
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func viewDidLoad() {
super.viewDidLoad()
tableview = UITableView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height), style: .grouped)
view.addSubview(tableview)
tableview.register(UINib(nibName: TableCell.nibName(), bundle: nil), forCellReuseIdentifier: TableCell.reuseIdentifier())
tableview.delegate = self
tableview.dataSource = self
}
}
有谁知道为什么会发生这种情况以及如何解决?
谢谢!
【问题讨论】:
-
显示你的单元格类
-
@jawadAli 不相关。看看 Sweeper 的回答。
-
太棒了..很高兴知道你得到了答案