【发布时间】:2019-03-25 03:33:29
【问题描述】:
我有一个单元格的课程
import UIKit
class LinkCellView: UITableViewCell {
@IBOutlet weak var cellTitleLabel: UILabel!
@IBOutlet weak var tagsListView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
我将tagsListView填入cellForRowAt
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "linkCell", for: indexPath) as! LinkCellView
let object = links[indexPath.row]
cell.cellTitleLabel!.text = object.description
let tag = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 21))
tag.text = "Frkul"
cell.tagsListView.addSubview(tag)
return cell
}
不幸的是,当我在模拟器中运行应用程序时,标签列表在那里几乎看不到。我的期望是看到整个标签列表。
我对 iOS 开发还很陌生,所以我可能缺少一些设计 iOS UI 的基本知识。如果无法直接回答这个问题,请指点我一个教程/网络研讨会,让新手了解这个主题。
- Xcode 10.0 版
- iOS 12
- iOS 模拟器 10.0 版
应用程序的静态版本 — https://gitlab.com/lipoqil/stackview-in-table-cell
【问题讨论】:
-
共享单元格中每个项目的约束
-
我更新了IB截图
-
使用自动布局而不是 CGRect
-
@codeByThey 对不起,我需要例子。我不知道你写的是什么意思。
-
我添加了应用静态演示的链接
标签: ios swift uitableview user-interface