开发者

Triple Component - pass data from picker to another view page text field

I have a triple component picker that I am trying to sen开发者_StackOverflow社区d the info to another view into text fields. I have it set up right now to go to an alert. If anyone has code or the know how to send the data from the triple component picker to another view please let me know. i have been trying for weeks now..and have had no answers that help. thanks in advance (a noobie) haha

#import  
#define kOneComponent 0 
#define kTwoComponent 1 
#define kThreeComponent 2 
interface FirstViewController : UIViewController UIPickerViewDelegate, UIPickerViewDataSource 
{ IBOutlet UIPickerView *doublePicker; 
NSArray *oneTypes; 
NSArray *twoTypes; 
NSArray *threeTypes; } 
property (nonatomic,retain) UIPickerView *doublePicker; 
property (nonatomic,retain) NSArray *oneTypes; 
property (nonatomic,retain) NSArray *twoTypes; property (nonatomic,retain) NSArray *threeTypes; 

-(IBAction)buttonPressed; 

end


I hope the following code will get you some idea!

// First component
int selected_1 = [pickerView selectedRowInComponent:0];
NSString *str_1 = [firstComponentValueArray objectAtIndex:selected_1];

// Second component
int selected_2 = [pickerView selectedRowInComponent:1];
NSString *str_2 = [secondComponentValueArray objectAtIndex:selected_2];

// Third component
int selected_3 = [pickerView selectedRowInComponent:2];
NSString *str_3 = [thirdComponentValueArray objectAtIndex:selected_3];

// Do what you want with these values and pass it to a view


You can use UIPicker delegate method

 - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

If the another view is done separately as controller you will need to set properties, which represents text fields of this class in the above method.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜