Search code examples
iosswiftwatchkit

Add target to button on a tableView row on Apple Watch


I have a row controller set up with a button. How can I make it so when it's pressed, the background image changes with an animation? I can't do it in the RowController file because you cannot call animateWithDuration.

Any help greatly appreciated.


Solution

  • You can implement the following method for row selection and in this method you can put the animation code.

    -(void)table:(WKInterfaceTable *)table didSelectRowAtIndex:(NSInteger)rowIndex{}
    

    Also Apple do not allow to programmatically set target for WKInterafaceButton, you need to implement that via storyboard.