I'm using Xcode 7 and I'm trying to pass a value from the picker to another function when a button is pressed. Is it possible to get the value of the row that is currently selected in the picker? Or do I have to use the picker as the button somehow? I tried implementing didSelectRow but when I try setting it up, I get an error: Use of undeclared type 'UIPicker View.' I'm guess I have to retrieve the index of the source array somehow.
Asked
Active
Viewed 693 times
2 Answers
3
UIKit
is not available for Apple Watch, and it is specially designed for iOS. Else you must use WatchKit
.
In order to use user interface (UI
) elements in your WatchKit App (watchOS1 or 2), you must use WatchKit (WK
) elements instead, such as WKInterfaceButton
.
So in order to have your app running successfully, replace UIPicker
(which is an UIKit
element) with WKInterfacePicker
(which is a WatchKit
element).
Note that WKInterfacePicker
will only work in watchOS 2 (or later).

Seyed Parsa Neshaei
- 3,470
- 18
- 30
-
Does anybody know what the method is for getting the row index? I'm trying to google but can't seem to find it. I also have checked the apple documentation about wkinterfacepickers but to no avail. – Aj Langley Aug 16 '15 at 14:18
2
You are trying to use a UIKit class.
Use Watchkit classes with watch os 2:
WKInterfacePicker

Gerd Castan
- 6,275
- 3
- 44
- 89