gpt4 book ai didi

swift - 为segue延迟做好准备。信息滞后但正在呈现

转载 作者:行者123 更新时间:2023-11-30 13:31:42 32 4
gpt4 key购买 nike

我正在将 otherUserUid 和 otherUserFullName 推送到另一个 View Controller ,但它不会立即被调用。信息滞后,需要点击2次信息才会出现。

我认为在 didSelectRowAtIndexPath: 之前调用了 preparForSegue: 有解决方案如何解决此问题吗?

干杯!

覆盖 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)

关于swift - 为segue延迟做好准备。信息滞后但正在呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36505387/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com