Use didSelectRowAtIndexPath or prepareForSegue method for UITableView?

前端 未结 6 526
不思量自难忘°
不思量自难忘° 2020-11-29 16:38

I\'m using storyboards and I have a UITableView. I have a segue setup that pushes from my table to the detail VC. But which method should I use to handle this? I\'ll have

6条回答
  •  难免孤独
    2020-11-29 16:47

    If you use prepareForSegue: you can check who is the sender and execute different code

    For example in swift

    override func prepareForSegue(segue: UiStoryboardSegue, sender: AnyObject?)
    {
       var senderIsTableviewCell:Bool! = sender?.isKindOfClass(UITableViewCell)
    
       if senderIsTableviewCell
       {
           //do something
       }
    }
    

提交回复
热议问题