TableView没有出现在我的容器中

tloz1506996

我对苹果开发绝对是新手。我目前正在使用主要细节概念构建iPad。在我的详细信息视图中,我有一些基本元素(例如文本字段等)以及一个容器,并且在该容器内是tableView。我正在遵循此指南:https : //www.youtube.com/watch?v=AaCfwqzH9SQ

我的问题是我的虚拟数据没有出现在表视图中。这只是一张空桌子。但是它确实打印出了我包含在viewDidLoad方法中的日志消息。

从容器到表格视图具有嵌入式序列的容器布局

这是我的类多数民众赞成在连接到表视图:

import UIKit

class TaskTableViewController: UITableViewController {

var Array = [String]()

override func viewDidLoad() {
    super.viewDidLoad()
    print("IN THE TASKBAR")
    Array = ["ffff","ddd","sss"]

    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
     self.navigationItem.rightBarButtonItem = self.editButtonItem
}

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

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // #warning Incomplete implementation, return the number of rows
    return Array.count
}


override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 


    //THIS IS WHER YOU'D PROGRAM YOUR TASK THINGS
    cell.textLabel?.text = Array[indexPath.row]

    // Configure the cell...


    return cell
}


/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
    // Return false if you do not want the specified item to be editable.
    return true
}
*/

/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        // Delete the row from the data source
        tableView.deleteRows(at: [indexPath], with: .fade)
    } else if editingStyle == .insert {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }    
}
*/

/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {

}
*/

/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
    // Return false if you do not want the item to be re-orderable.
    return true
}
*/

/*
// 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.
}
*/

}

赛义德·卡马尔·阿巴斯

numberOfSections不应该返回zero要在您tableView的至少一个区域中显示一些单元格,应该可用。

override func numberOfSections(in tableView: UITableView) -> Int {
    // #warning Incomplete implementation, return the number of sections
    return 1
}

reloadData在您向其中插入内容后,还调用tableViewArray

override func viewDidLoad() {
    super.viewDidLoad()
    print("IN THE TASKBAR")
    Array = ["ffff","ddd","sss"]
    self.tableView.reloadData()
    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
     self.navigationItem.rightBarButtonItem = self.editButtonItem
}

假设此方法将在单击按钮时执行。

func didClickedOnEditButton(button: UIButton){
    //First add string into your array
    Array.append("This is the newly inserted String")
    //Then ask your TableView to reload Everything
    tableView.reloadDate()
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

QRectF没有出现在我的QGraphicsScene中

Entry() 没有出现在我的程序中

我返回的答案没有出现在标签中

我选择的图像没有出现在预览中

为什么我的 MUI 分隔线没有出现在 MUI 容器或纸张中?

这些变量从哪里出现在我的kubernetes容器中?

为什么线条在我的SVG元素中没有出现在我的圈子中

我的页脚没有出现在页面底部,而是出现在页面中间

导航栏没有出现在我的页面顶部,出现在怪异的地方

为什么我的 vtt 字幕没有出现在我的 html5 视频中?

为什么我的json没有出现在我的参数中?

为什么我的嵌套 div 内容缩小并且我没有声明的空间出现在 div 容器之间?

ListView没有出现在我的应用程序的MainActivty中(附有图像)

在R中,为什么变量名称以'。'开头 没有出现在我的环境中?

我的 Google Sheet 中的数据没有出现在正确的单元格中

AdMob没有出现在我的SpriteKit游戏中

动画背景没有出现在我希望的地方

UIView 没有出现在我的根 UIViewController 上

为什么数据出现在突变上,但没有出现在查询中?

为什么我的log4j消息没有出现在日志文件中?

我的代码都没有出现在Golang内存分析器输出中

我的表单字段没有出现在html文件中

为什么我的vue.app没有出现在部署版本中?

为什么我的视图没有出现在angular-ui-router中?

UILabel没有出现在我的应用程序中

css 文件没有出现在我的实时 github 页面应用程序中

为什么我的文本没有出现在微调器中的图像视图中?

为什么我的用户名没有出现在 TextView 中?

包含文件夹没有出现在我的Qt项目树中