无法将UIScrollView设置为在UITableViewCell

时间:2015-05-26 09:58:42

标签: ios uitableview swift uiscrollview

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

我设置了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

1 个答案:

答案 0 :(得分:1)

有两个地方需要更改或添加scrolling.contentSize = sizecell.contentView.userInteractionEnabled = true