Ios 使用UITableViewController将视图固定到底部
当我在我的Ios 使用UITableViewController将视图固定到底部,ios,swift,uitableview,uiview,Ios,Swift,Uitableview,Uiview,当我在我的UITableView中滚动时,我想在底部粘贴一个UIView 我的想法是设置一个ui视图,其位置在导航项的正上方。将其zPosition设置为1 问题是,我的UITableView的y位置不同。 你知道怎么解决这个问题吗 编辑: 提供可视和预期行为的屏幕截图: 可见: 这是我滚动的时候: 预期: 如表上打火机摄像头符号所示: Edit2: 这段代码就是我用来将矩形放在底部的代码。 它一直工作到我滑动UITableView-矩形也会向上滚动 let bounds = self.vi
UITableView
中滚动时,我想在底部粘贴一个UIView
我的想法是设置一个ui视图
,其位置在导航项的正上方。将其zPosition
设置为1
问题是,我的UITableView
的y位置不同。
你知道怎么解决这个问题吗
编辑:
提供可视和预期行为的屏幕截图:
可见:
这是我滚动的时候:
预期:
如表上打火机摄像头符号所示:
Edit2:
这段代码就是我用来将矩形放在底部的代码。
它一直工作到我滑动UITableView
-矩形也会向上滚动
let bounds = self.view.bounds
let yPosition = self.navigationController?.toolbar.frame.minY
print(yPosition)
let myView = UIView(frame: CGRect(x: 0, y: yPosition! - bounds.height/6, width: bounds.width, height: bounds.height/6))
myView.backgroundColor = myColor.rookie
myView.alpha = 0.8
myView.layer.zPosition = 1
myView.isUserInteractionEnabled = true
self.view.addSubview(myView)
有一个解决办法。您可以通过禁用相应按钮或浮动按钮的任何UIView的自动布局(button.translatesAutoResizezingMaskinToConstraints=false)属性来完成此操作:
斯威夫特4
button.translatesAutoresizingMaskIntoConstraints = false
if #available(iOS 11.0, *) {
button.rightAnchor.constraint(equalTo: tableView.safeAreaLayoutGuide.rightAnchor, constant: -10).isActive = true
button.bottomAnchor.constraint(equalTo: tableView.safeAreaLayoutGuide.bottomAnchor, constant: -10).isActive = true
} else {
button.rightAnchor.constraint(equalTo: tableView.layoutMarginsGuide.rightAnchor, constant: 0).isActive = true
button.bottomAnchor.constraint(equalTo: tableView.layoutMarginsGuide.bottomAnchor, constant: -10).isActive = true
}
为什么不使用tablefooterview?是否需要成为UITableViewController而不是UIViewController?预期与观察的屏幕截图将是一个加号。@Venkat页脚视图始终位于tableview的底部,但它超出了视图的范围。这需要一直保持下去visible@JVS-好的。。。看看这篇文章——它讨论了做你想做的事情的几种方法。