1

I recently started to learn and trying to develop a project for Apple Watch support for one of my iPhone projects, where i have WKInterfaceButton object on every RowController in WKInterfaceTable, i want to handle its action to access underlying datasource array for updating some thing. On iPhone/iPad usually we do it by assigning Indexpath as UIButton's tag property and based on the tag value we access datasource array position, but seems like there is no tag property available in WKInterfaceButton on watch kit, so please if any one knows best way to get the index of WKInterfaceButton clicked at, to get value of index in its target method. It would be so helpful for me as i was stucked on it, please help me if you come across same problem before.

Teja Kumar Bethina
  • 3,486
  • 26
  • 34
Lk Thanvi
  • 87
  • 1
  • 9

2 Answers2

1
  1. Write a method in the "row view". e.g. - (IBAction) btnTurnOnOffClicked ;
  2. Select your button in the "row view" design for table in the Interface.storyboard.
  3. When you select WKInterfaceButton object, you can find "Sent Actions" in the Utilities Panel.
  4. Drag and bind to your "row view" method.

image

Hayley Guillou
  • 3,953
  • 4
  • 24
  • 34
Liddle
  • 19
  • 4
-1

I haven't tried this but I imagine that if you add an integer property (e.g. "tag") to your rowController class and set this to some unique value (maybe the row number) as the rows are created then put the button action method in the rowController class and it can interrogate the tag property value to identify which row was tapped.

user3771857
  • 617
  • 5
  • 3