【发布时间】:2016-11-21 18:44:42
【问题描述】:
我正在做以下工作: Screenshot
基本上它是一个 UIImageView 在另一个 UIImageView 的顶部(屏幕的 60%)和一个 UITableView 占据屏幕的 40%
和代码(见下文):
我想要实现的是在单击我的 customCell 时调整 UITableView 全屏单元格的大小,并在未单击时将其大小调整为原始状态。
有什么办法可以使这个工作吗? 提前致谢。
//Label outlets
@IBOutlet weak var tableView: UITableView!
var selectedIndexPath : IndexPath? = nil
override func viewDidLoad() {
super.viewDidLoad()
//MARK Start of CustomViewCell Code
tableView.register(UINib(nibName: "CustomViewCell", bundle: nil), forCellReuseIdentifier: "Cell")
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! CustomViewCell
cell.clipsToBounds = true
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let index = indexPath
if selectedIndexPath != nil {
if index == selectedIndexPath {
return 667
} else {
return 62
}
} else {
return 62}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch selectedIndexPath {
case nil:
selectedIndexPath = indexPath
default:
if selectedIndexPath! == indexPath {
selectedIndexPath = nil
} else {
selectedIndexPath = indexPath
}
}
tableView.reloadRows(at: [indexPath], with: .automatic)
}
//MARK End of CustomViewCell Code
【问题讨论】:
-
你要全屏的
tableViewCell的内容是什么?那有imageView吗? -
没有@Santosh
labelsandtextView
标签: ios iphone swift uitableview uiimageview