How does one bind an iPhone SDK control (say a UISlider) using Interface Builder?
Unlike regular Cocoa applications, the bindings tab does not seem to be present when the iPhone-app XIB is opened using Interface Builder
Cocoa bindings is not available in the iPhone SDK. You have to do everything "by hand" much as you used to have to do on the Mac.
Declare the control as an IBOutlet in your viewcontroller .h file. In IB, set the File's Owner for the view as your viewcontroller class (Select File's owner, in Inspector window click on the (i) button and set the class as your viewcontroller) Now with the File's Owner selected, click on the blue button with a white arrow in the Inspector window. Bind the IBOutlet for your UISlider to the UISlider on your view.
To get the value of the slider when it changes, create a method in the viewcontroller with the return type IBAction. In the inspector window, if you connect this to the UISlider, it gives you multiple options to select from. Select the "Value changed" option. Now every time the value of the slider is changed your IBAction method will be called.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With