我需要在UIScrollView
中添加UITableView
,但它不起作用。
我设置了scrollEnabled
,alwaysBounceVertical
,delaysContentTouches
,canCancelContentTouches
,但仍然相同。
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
答案 0 :(得分:1)
有两个地方需要更改或添加scrolling.contentSize = size
和cell.contentView.userInteractionEnabled = true