开发者

Xcode: UIPickerView Text & View Controller Link Up

I have created two view controllers in XCode along with a UIPicker开发者_JAVA百科View, a label, a text view. I wanted to try and get data from the UIPickerView, so when the app detects that a row has been selected, it will automatically set the label to the value of the row in the UIPickerView. I also wanted certain descriptions for certain selected rows.

See some screenshots of my app here to further understand what it is I am trying to do;

1) http://cl.ly/102K3p2v433N0F1c0m2i - main screen

2) http://cl.ly/102K3p2v433N0F1c0m2i - selected row after lever has been "pulled"

3) http://cl.ly/2d1D2D1Z1s0k053Z2C3H - view controller pops up but the label/description still have default values

Here is my code;

1) (MAIN SCREEN) TroubleMakerViewController.h - http://pastie.org/2466793

2) (MAIN SCREEN) TroubleMakerViewController.m - http://pastie.org/2466795

3) (RESULTS SCREEN) Results.h - http://pastie.org/2466805

4) (RESULTS SCREEN) Results.m - http://pastie.org/2466808

Can somebody explain why the label and description text is showing the default text rather than what I have set it to do? Everything is linked up properly in the XIB files.


You need to implement the UIPickerViewDelegate method pickerView:didSelectRow:inComponent: as described in the documentation to be notified as soon as the currently selected value changes. In this method just simply update the text of your label ;-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜