2

I'm creating a Tableview programatically with the following code:

 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
 }

and adding in ViewAutoComplete created programatically too

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)
}

The problem is that the contentView is smaller than cell and tableview like the following screenshots

enter image description here

enter image description here

sdadsad
  • 143
  • 1
  • 12

1 Answers1

0

I solved my problem following

iOS 8 UITableView separator inset 0 not working instructions about separator insets

I just added the following code to my viewDidLayoutSubviews

tbStores.cellLayoutMarginsFollowReadableWidth = false;
Community
  • 1
  • 1
sdadsad
  • 143
  • 1
  • 12