ios - 无法将 UIScrollView 设置为在 UITableViewCell 中滚动

标签 ios uitableview swift uiscrollview

我需要在 UITableView 中添加 UIScrollView,但它不起作用。

我设置了scrollEnabledalwaysBounceVerticaldelaysContentTouchescanCancelContentTouches,但还是一样。

var scrolling: UIScrollView = UIScrollView(frame: CGRectMake(0,0,self.view.frame.width,50))
scrolling.userInteractionEnabled = true

var style1: NSMutableParagraphStyle = NSMutableParagraphStyle()
style1.lineBreakMode = .ByWordWrapping
style1.alignment = .Center
var attributedString = NSMutableAttributedString(string:"\(newsValue_withPrintintFormat[indexPath.section][indexPath.row])", attributes: [NSFontAttributeName: UIFont.systemFontOfSize(15)])
var ns_range1:NSRange = NSMakeRange(0,attributedString.length)
attributedString.addAttribute(NSParagraphStyleAttributeName, value: style1, range: ns_range1)


var content = UILabel( frame: CGRect(x: 10,y: 0,width: self.view.frame.width-10 ,height: size.height) )
content.attributedText = attributedString
content.numberOfLines = 0
content.lineBreakMode = .ByWordWrapping
content.sizeToFit()
scrolling.contentSize = size

scrolling.addSubview(content)
scrolling.sizeToFit()
scrolling.delegate = self
scrolling.scrollEnabled = true
scrolling.alwaysBounceVertical = true
scrolling.delaysContentTouches = true
scrolling.canCancelContentTouches = false
cell!.contentView.addSubview(scrolling)
cell.contentView.userInteractionEnabled = false

最佳答案

有 2 个地方需要更改或添加,分别是 scrolling.contentSize = sizecell.contentView.userInteractionEnabled = true

关于ios - 无法将 UIScrollView 设置为在 UITableViewCell 中滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30455300/

相关文章:

IOS什么是顶部图像和其余表格 View 的 View

ios - 使用 UIActivityViewController 提供不同格式的数据

ios - 仅在某些设备上出现核心数据标量错误

iphone - touchesBegan 没有响应

ios - 如何将 content_available 添加到 Firebase Notification Composer

ios - 快速将图像从设备加载到 tableView

ios - Swift 在 UITableView 中创建分页

ios - 刷新表格查看外观

Swift 和谷歌地图 SDK。与桥接头混淆

ios - InstantiateViewController 导致 nil 导致它崩溃