gpt4 book ai didi

ios - 在 UITableView 中水平滚动以查看 Xcode 6 和 Swift 中的长单元格

转载 作者:行者123 更新时间:2023-11-29 02:30:53 25 4
gpt4 key购买 nike

我创建了一个 tableviewcontroller 并向其添加了一个 TableView 。我需要的只是通过向右滑动来查看一个长单元格(或行)。我怎样才能做到这一点? enter image description here

最佳答案

只需在 tableCell 中添加一个简单的 UIScrollView,如下所示。这将允许您在单元格内进行水平滚动。

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as UITableViewCell

// Configure the cell...

/// Horizontal Scroll

var scrollview = UIScrollView(frame: cell.bounds)
scrollview.contentSize = CGSizeMake(cell.bounds.width * 5, cell.bounds.height) // will be 5 times as wide as the cell
scrollview.pagingEnabled = true

cell.contentView.addSubview(scrollview)

return cell
}

关于ios - 在 UITableView 中水平滚动以查看 Xcode 6 和 Swift 中的长单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26891024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com