TableView并不完全正确

时间:2015-08-25 13:17:00

标签: xcode6

我将数据(值)从ViewController传递给TableView(见下文),但tableview只填充第一行。它不算数。我该如何解决?

tableview应显示新行中的每个传递数据。

 @IBAction func a(sender: UIButton) {
           txtBalkenbewehrung = ausgabe.text        
        performSegueWithIdentifier("transferfile", sender: sender)        
    }                                                                                  
   import UIKit
   var txtBalkenbewehrung: String?

class EBTableViewController: UITableViewController, UITableViewDelegate, UITableViewDataSource {



    var rowData = [txtBalkenbewehrung]



    override func viewDidLoad() {
        super.viewDidLoad()
        self.tableView.editing = true
        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()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Potentially incomplete method implementation.
        // Return the number of sections.
        return 1
    }

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


    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
       let cell = tableView.dequeueReusableCellWithIdentifier("textcell",
            forIndexPath: indexPath) as! UITableViewCell
        // let data = rowData[indexPath.row]
        cell.textLabel!.text = rowData[indexPath.row]


        return cell

    }

`

1 个答案:

答案 0 :(得分:0)

首先,请确保您正确格式化代码!

行为似乎是连贯的,因为数据是一个包含单个元素的数组,txtBalkenbewehrung

如果要显示多个

,则需要使用更多元素填充数组