我正在使用以下代码以编程方式创建Tableview:
override func viewDidLayoutSubviews() {
//@begin store selection - settings
self.tbStores = UITableView(frame: CGRect(x: 15, y: 60, width: UIScreen.main.bounds.size.width - 30, height: 150))
self.tbStores.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
tbStores.backgroundColor = UIColor.white
tbStores.delegate = self
tbStores.dataSource = self
tbStores.allowsSelection = true;
tbStores.translatesAutoresizingMaskIntoConstraints = true
}
并添加以编程方式创建的ViewAutoComplete
if (viewAutoComplete == nil) {
self.viewAutoComplete = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height))
viewAutoComplete.backgroundColor = UIColor(red: 32 / 255.0, green: 48 / 255.0, blue: 90 / 255.0, alpha: 1)
viewAutoComplete.alpha = 1
viewAutoComplete.translatesAutoresizingMaskIntoConstraints = true
self.viewAutoComplete.tag = 123
self.view!.addSubview(viewAutoComplete)
viewAutoComplete.addSubview(tbStores)
}
问题是contentView小于单元格和tableview,如以下屏幕截图所示
最佳答案
我解决了我的问题
iOS 8 UITableView separator inset 0 not working有关分隔符插入的说明
我刚刚将以下代码添加到我的viewDidLayoutSubviews中
tbStores.cellLayoutMarginsFollowReadableWidth = false;
关于ios - Tableview的contentView小于Tableview框架和单元格,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40530353/