以下是问题的屏幕截图:
这是我在vIEwDIDLoad中使用的代码:
refreshControl = UIRefreshControl() refreshControl.tintcolor = UIcolor.redcolor() refreshControl.addTarget(self,action: "handleRefresh:",forControlEvents: UIControlEvents.ValueChanged) tableVIEw.insertSubvIEw(refreshControl,atIndex: 0) tableVIEw.sendSubvIEwToBack(refreshControl)
这就是我创建标题的方式:
func tableVIEw(tableVIEw: UItableVIEw,willdisplayheaderVIEw vIEw: UIVIEw,forSection section: Int) { let header: UItableVIEwheaderfooterVIEw = vIEw as! UItableVIEwheaderfooterVIEw //recast vIEw as a UItableVIEwheaderfooterVIEw header.contentVIEw.backgroundcolor = UIcolor(red: 59/255,green: 134/255,blue: 134/255,Alpha: 1.0) //make the background color light blue header.textLabel.textcolor = UIcolor.whitecolor() //make the text white header.Alpha = 0.5 //make the header transparent }
非常感谢 !
解决方法 使用tableVIEw.addSubvIEw(refreshControl)应该可以正常工作.检查故事板,如果没有导航栏,则禁用“在顶部X下扩展”选项,如果确实已启用它们.如果全部失败,您如何创建标题视图?如果他们被创建&像表中的常规单元格一样返回
let headerCell = tablevIEw.dequeueReusableCellWithIDentifIEr("headerCell") as! UItableVIEwCell
在返回之前尝试将它们包装在UIVIEw中
let vIEw : UIVIEw = UIVIEw(frame: headerCell.vIEw.frame)vIEw.addSubvIEw(headerCell.vIEw)return vIEw
有时,当表视图将这些标题视为常规表单元格并且抱怨缺少索引路径时,会出现此问题,因为它们会破坏布局.
总结以上是内存溢出为你收集整理的在Swift中实现pull to Refresh时,Table View标头卡住了全部内容,希望文章能够帮你解决在Swift中实现pull to Refresh时,Table View标头卡住了所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)