Reputation: 63
I'm pushing otherUserUid and otherUserFullName to another view controller but it isn't being call immediately. The information is lagging behind and it takes 2 clicks for the information to appear.
I think preparForSegue: is being called before didSelectRowAtIndexPath: Any solutions how to fix this?
Cheers!
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
}
Upvotes: 0
Views: 429
Reputation: 894
in didSelectRowAtIndexPath you have to perform segue at the end of Function like thiss..
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)
Upvotes: 0