Я создал таблицу в storyborad. Но я инициализирую его из кода. Проблема в том, когда я inialize из кода он не показывает клетки, мои клетки statycTableviewcontroller не показывает ячейки
это мой код контроллера Tableview:
class AutorizedProfileTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
tableView.backgroundView=UIImageView(image: #imageLiteral(resourceName: "bg_profile"))
//tableView.backgroundColor=UIColor(colorLiteralRed: 69/255, green: 69/255, blue: 69/255, alpha: 0.3)
tableView.tableFooterView=UIView()
tableView.reloadData()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 7
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == 0{
return 250
}
else{
return 50
}
}
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cell.backgroundColor=UIColor.clear
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
и это это как его инициализировать из кода:
if (UIApplication.shared.delegate as! AppDelegate).currentcookie[HTTPCookiePropertyKey.value] != nil{
let menuTable=AutorizedProfileTableViewController().self
let size=UIScreen.main.bounds.size
menuTable.view.frame=CGRect(x: size.width-(size.width*3/4), y: 0, width: size.width*3/4, height: size.height)
profile.addSubview(menuTable.view)
}else{
let menuTable=NoAutorizedProfileTableViewController()
let size=UIScreen.main.bounds.size
menuTable.view.frame=CGRect(x: size.width-(size.width*3/4), y: 0, width: size.width*3/4, height: size.height)
profile.addSubview(menuTable.view)
}
self.navigationController?.view.addSubview(profile)
menuOpen=menuOpen ? false : true
if menuOpen{
self.navigationController?.view.isUserInteractionEnabled=false
self.navigationController?.view.bringSubview(toFront: profile)
}
else{
self.navigationController?.view.isUserInteractionEnabled=true
profile.removeFromSuperview()
}
W шляпы - проблема, почему я не вижу свои ячейки?
Вы не получите сообщение об ошибке/предупреждение об отсутствии 'cellForRowAtIndexPath'? Поскольку контроллер сконструирован в раскадровке, инициализатор по умолчанию 'AutorizedProfileTableViewController()' никогда не возвращает объект в раскадровке. – vadian
Вы пропускаете свой метод cellForRowAt? проверьте мой ответ http://stackoverflow.com/questions/40205397/ios-swift3-tableview-simple-display-value/40206096#40206096 – Joe