我正在尝试创建一个屏幕,其中包含一些UIElements
和一个UITableView
。
为了使所有内容都可滚动,我实现了UITableView
和tableHeaderView
,其中包含UIElements
。
现在,视图无法正确滚动显示所有UITableViewCells
。
这是我到目前为止所遵循的步骤:
UIView
及其Subviews
UIView
设置为table.tableHeaderView
data
。我到底错过了什么?
编辑:三个步骤的代码
1,2。
let bounds = UIScreen.mainScreen()。bounds
imageSliderVC = TNImageSliderViewController()
imageSliderVC.view.frame = CGRectMake(0, 0, bounds.width, bounds.width)
layerView = UIView(frame: CGRectMake(0, 0, bounds.width, bounds.width))
layerView.alpha = 0.25
layerView.backgroundColor = UIColor.blackColor()
noButton = constructNopeButton()
yesButton = constructLikedButton()
buttonOptionsApply()
nameLbl = UILabel(frame: CGRectMake(20, layerView.frame.maxY + 20, bounds.width-40, 20))
nameLbl.makeNameLabelFormat()
hashtagLbl = UILabel(frame: CGRectMake(20, nameLbl.frame.maxY + 5, bounds.width-40, layerView.frame.width/3.66))
hashtagLbl.makeHashtagFormat()
seperatorLbl = UILabel(frame: CGRectMake(20, hashtagLbl.frame.maxY + 15, bounds.width-40, 1))
seperatorLbl.backgroundColor = UIColorFromRGB(0x9B9B9B)
groupsLbl = UILabel(frame: CGRectMake(20, seperatorLbl.frame.maxY + 15, 30, 20))
groupsLbl.text = "Groups:"
groupsLbl.makeNameLabelFormat()
groupsLbl.sizeToFit()
groupsCountLbl = UILabel(frame: CGRectMake(groupsLbl.frame.maxX + 5, seperatorLbl.frame.maxY + 15 , 40, 20))
groupsCountLbl.sizeToFit()
let myView = UIView(frame: CGRectMake(0,0,bounds.width, groupsCountLbl.frame.maxY + 10))
myView.addSubview(imageSliderVC.view)
myView.addSubview(layerView)
myView.addSubview(noButton)
myView.addSubview(yesButton)
myView.addSubview(nameLbl)
myView.addSubview(hashtagLbl)
myView.addSubview(seperatorLbl)
myView.addSubview(groupsLbl)
myView.addSubview(groupsCountLbl)
table.tableHeaderView = myView
答案 0 :(得分:0)
我通过在IB中实施UITableViewController
而不是普通的UIViewController
并TableView
解决了这个问题