Custom UITableViewCell not calling prepareForSegue

前端 未结 4 967
刺人心
刺人心 2021-02-14 00:00

I have a custom UITableViewCell, called EventCell.

EventCell.h

#import 

@interface EventCell : UITabl         


        
4条回答
  •  感情败类
    2021-02-14 00:23

    You shouldn't have to implement didSelectRow for this to work - control-dragging from a cell to another view controller should create a segue that works when tapping the cell.

    In my case, the problem was that the storyboard editor was creating the segue incorrectly. I had two very similar storyboards, one worked and the other didn't, and looking at the source code (right click on the storyboard file and choose Open As -> Source Code), I saw this:

    
    

    Note the trigger attribute. This suggests to me that the segue will be fired from the accessory action of the cell. You can even see this from the connections inspector of the cell:

    enter image description here

    Removing this and replacing the segue by dragging from the "selection" handle above instead of control-dragging from the cell gave me the correct segue.

    I'm not sure what it is about this particular cell that makes control-dragging connect to the accessory action instead of the selection action, but there you go.

提交回复
热议问题