准备 segue 延迟。信息滞后但正在呈现

Prepare for segue delay. Information is lagging but being presented

我正在将 otherUserUid 和 otherUserFullName 推送到另一个视图控制器,但没有立即调用它。信息滞后,需要点击 2 次才能显示信息。

我认为 preparForSegue: 在 didSelectRowAtIndexPath 之前被调用:任何解决方案如何解决这个问题?

干杯!

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    self.performSegueWithIdentifier("jsqDirectory", sender: self)
    let indexPath = tableView.indexPathForSelectedRow!

    let currentCell = tableView.cellForRowAtIndexPath(indexPath)! as UITableViewCell

    self.otherUserFullName = (currentCell.textLabel?.text)!
    print(self.otherUserFullName)

    self.otherUserUid = (currentCell.detailTextLabel?.text)!
    print(self.otherUserUid)

}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "jsqDirectory" {
        if let viewController = segue.destinationViewController as? JSQViewController{

            viewController.senderDisplayName = self.fullName
            viewController.senderId = self.firebase.authData.uid

            viewController.otherUid = self.otherUserUid
            viewController.otherUser = self.otherUserFullName
        }
    }
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("directoryCell") as UITableViewCell!
    let directoryItem = items[indexPath.row]

    cell.textLabel?.text = directoryItem.fullName
    cell.detailTextLabel!.text = directoryItem.key
    cell.detailTextLabel!.hidden = true

    return cell
}

在 didSelectRowAtIndexPath 中你必须像这样在 Function 的末尾执行 segue..

let indexPath = tableView.indexPathForSelectedRow!

let currentCell = tableView.cellForRowAtIndexPath(indexPath)! as UITableViewCell

self.otherUserFullName = (currentCell.textLabel?.text)!
print(self.otherUserFullName)

self.otherUserUid = (currentCell.detailTextLabel?.text)!
print(self.otherUserUid)
self.performSegueWithIdentifier("jsqDirectory", sender: self)