【发布时间】:2016-08-12 15:28:24
【问题描述】:
您好,我有一个动态 TableViewController,其中一个单元格包含一个图像和标签。我已经对所有这些设置了约束。问题是它没有正确查看。
这是它的查看方式
代码:
override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 103
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
tableView.setNeedsLayout()
tableView.layoutIfNeeded()
self.tableView.reloadData()
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
tableView.reloadData()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return newarray.count
}
override
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("requestcell", forIndexPath: indexPath) as! NewRequestTableViewCell
let image : UIImage = UIImage(named: "placeholder_product_image")!
cell.imageView!.image = image
cell.requestTitle.text = "IPHONE 6s PLUS"
cell.DestinationCountry.text = "Pakistan"
return cell
}
我不知道还能做什么。请帮助我怎样才能像我设计的那样排
【问题讨论】:
-
覆盖
tableView:heightForRowAtIndexPath:并返回UITableViewAutomaticDimension
标签: ios objective-c swift uitableview