使用解析检索密钥的所有对象

时间:2014-12-29 04:13:23

标签: uitableview swift uiviewcontroller ios8 xcode6

我有一个名为groupConversation的全局数组,该数组填充在另一个UIViewController中。首先,数组为空,但当用户单击另一个UIViewController中的按钮时,它将被填充。但是,UITableViewController出现在另一个UIViewController之前。但是当在另一个UIViewController中单击按钮同时填充数组时,它会将用户弹出UITableViewControllerUITableViewController为空,我不明白为什么?如何让UITableViewController包含数据?

import UIKit


class GroupChatTableViewController: UITableViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.navigationBar.tintColor = UIColor.redColor()
    self.navigationItem.backBarButtonItem?.tintColor = UIColor.redColor()


    println()


    // 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 viewWillAppear(animated: Bool) {
    self.navigationController?.navigationBar.tintColor = UIColor.orangeColor()
    self.navigationItem.backBarButtonItem?.tintColor = UIColor.orangeColor()
    self.tableView.reloadData()
}

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 groupConversation.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let groupChatCell = tableView.dequeueReusableCellWithIdentifier("groupChatCell", forIndexPath: indexPath) as UITableViewCell

    groupChatCell.textLabel?.text=groupConversation[indexPath.row]

    return groupChatCell
}


}

0 个答案:

没有答案