小编use*_*164的帖子

防止页脚在 UITableView 中重叠 tableViewCell - Swift

我有这个表格视图,它按照我想要的方式工作,但是我有一个问题,即页脚与表格视图中的单元格重叠,如图这个图片

我怎样才能防止这种情况?这是我的页脚代码

   func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {

    let footerView = UIView(frame: CGRectMake(0, 0, tableView.frame.size.width, 40))
    //    self.myTableView.tableFooterView = footerView;
    let sectionString = Array(foodArray.keys)[section]


      for value in caloriesArray[sectionString]! {
        calories += value
       }
       totalCalories += calories

      print(calories)
      print(totalCalories)
      let label = UILabel(frame: CGRectMake(footerView.frame.origin.x - 15, footerView.frame.origin.y, footerView.frame.size.width, 20))

       label.textAlignment = NSTextAlignment.Right

       label.text = "Total Calories: \(calories) "

      footerView.addSubview(label)
       calories = 0
  return footerView
  }

 func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {

  return 20.0
}

@IBAction …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

6
推荐指数
2
解决办法
3113
查看次数

标签 统计

ios ×1

swift ×1

uitableview ×1