Swift Tableview赢得';不要完全滚动到底部
我的table view不允许我使用tableviewCell.xib来创建它,我似乎找不到修复方法。下面是显示tableview是如何创建的代码Swift Tableview赢得';不要完全滚动到底部,swift,Swift,我的table view不允许我使用tableviewCell.xib来创建它,我似乎找不到修复方法。下面是显示tableview是如何创建的代码 //MARK: VIEW LIFECYLCE override func viewDidLoad() { super.viewDidLoad() //disable darkmode not going to be ready till later update due to time constraints
//MARK: VIEW LIFECYLCE
override func viewDidLoad() {
super.viewDidLoad()
//disable darkmode not going to be ready till later update due to time constraints
//==================================================
if #available(iOS 13.0, *) {
overrideUserInterfaceStyle = .light
} else {
// Fallback on earlier versions
}
//==================================================
print("the user logged in is \( String(describing: Auth.auth().currentUser?.email))")
tableview = UITableView(frame: view.bounds, style: .plain)
tableview.backgroundColor = UIColor.white
view.addSubview(tableview)
var layoutGuide : UILayoutGuide!
layoutGuide = view.safeAreaLayoutGuide
let cellNib = UINib(nibName: "dailyMotivationTableViewCell", bundle: nil)
//MARK: TABLEVIEW CONSTRAINTS
tableview.register(cellNib, forCellReuseIdentifier: "DailyThoughtCELL")
tableview.leadingAnchor.constraint(equalTo: layoutGuide.leadingAnchor).isActive = true
tableview.trailingAnchor.constraint(equalTo: layoutGuide.trailingAnchor).isActive = true
tableview.bottomAnchor.constraint(equalTo: layoutGuide.bottomAnchor).isActive = true
tableview.dataSource = self
tableview.delegate = self
//MARK: FUNCS
decideUserType()
loaddailymotivation()
}
下面是加载时的外观图片,它不会进入最后一篇文章的底部在函数中添加这行代码
tableView.translatesAutoresizingMaskIntoConstraints = false
在函数中添加这行代码
tableView.translatesAutoresizingMaskIntoConstraints = false
这是因为tabBar隐藏了表视图,所以您可以将此代码添加到ViewController中
让AdjustForTabArinsets:UIEdgeInsets=UIEdgeInsets(0,0,self.tabBar控制器!.tabBar.frame.height,0)
self.yourTableView.contentInset=adjustfortabarinsets
self.yourTableView.ScrollIndicationSets=AdjustForAbarinsets
由于选项卡栏的缘故,它隐藏了表格视图,因此您可以将此代码添加到ViewController中
让AdjustForTabArinsets:UIEdgeInsets=UIEdgeInsets(0,0,self.tabBar控制器!.tabBar.frame.height,0)
self.yourTableView.contentInset=adjustfortabarinsets
self.yourTableView.ScrollIndicationSets=AdjustForAbarinsets
您的另一个选项
self.tableview.contentInset.bottom=self.tabBar控制器?.tabBar.frame.height??0
您的另一个选择
self.tableview.contentInset.bottom=self.tabBar控制器?.tabBar.frame.height??0