Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7690451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:24:01+00:00 2026-05-31T20:24:01+00:00

Ok I am having trouble figuring out how to approach this. I have a

  • 0

Ok I am having trouble figuring out how to approach this.

I have a UITextField which I add to a UITableView dynamically according to the definitions of a XML file, in the XML file I may specify a list as one of the data types and what I do then is add a UIPickerView that displays the list to the inputView of my specific UITextField.

What I am having trouble with is figuring out how to take the selected value from the UIPickerView and add it to the text property of my UITextField

My UIPickerView is a custom class but I added no extra functionality I only overrode it to make it possible to pass a datasource to the UIPickerView as a property.

Here is my PickerViewDataSourceAndDelegate.h

#import <Foundation/Foundation.h>

@interface PickerViewDataSourceAndDelegate : UIPickerView <UIPickerViewDelegate, UIPickerViewDataSource>

@property (nonatomic, strong) NSMutableArray *pickerData;

@end

And it’s .m file

#import "PickerViewDataSourceAndDelegate.h"

@implementation PickerViewDataSourceAndDelegate 

@synthesize pickerData;

-(id)init {
    if (self = [super init])
    {
        self.pickerData = [[NSMutableArray alloc] init];
    }
    return self;
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {

    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
    return [self.pickerData count];
}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    return [self.pickerData objectAtIndex:row];
}

@end

This is how I add the UITextField with the UIPickerView as inputView

    for(NodeProperty *nodeproperty in node.properties)
    {
        if(nodeproperty.flowDirection == (FlowDirection*)Output)
        {
            if([nodeproperty.typeName isEqualToString:@"System.String"] && nodeproperty.extendedType == (ExtendedType*)None && [nodeproperty.enumValues count] == 0)
            {
                ...
            }
            else if([nodeproperty.typeName isEqualToString:@"System.String"] && nodeproperty.extendedType == (ExtendedType*)MultilineText && [nodeproperty.enumValues count] == 0)
            {
                ...
            }
            else if([nodeproperty.typeName isEqualToString:@"System.Boolean"] && nodeproperty.extendedType == (ExtendedType*)None && [nodeproperty.enumValues count] == 0)
            {
                ...
            }
            else if([nodeproperty.typeName isEqualToString:@"System.Double"] && nodeproperty.extendedType == (ExtendedType*)None && [nodeproperty.enumValues count] == 0)
            {
                ...
            }
            else if([nodeproperty.typeName isEqualToString:@"System.String"] && nodeproperty.extendedType == (ExtendedType*)None && [nodeproperty.enumValues count] > 0)
            {
                UILabel *fieldLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 290, 20)];
                fieldLabel.text = nodeproperty.name;
                [rowsInSectionLabels addObject:fieldLabel];

                PickerViewDataSourceAndDelegate *pickerDataDel = [[PickerViewDataSourceAndDelegate alloc] init];

                pickerDataDel.pickerData = nodeproperty.enumValues;
                pickerDataDel.dataSource = pickerDataDel;
                pickerDataDel.delegate = pickerDataDel;

                UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(5, 25, 290, 30)];
                [textField setBorderStyle:UITextBorderStyleRoundedRect];
                textField.inputView = pickerDataDel;
                [rowsInSection addObject:textField];
            }
            else
            {
              ....

For space I omitted some of the space, if some things are unclear I will gladly explain.

Every thing works perfectly with no exceptions, I just want to get the selected value out of the picker

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:24:03+00:00Added an answer on May 31, 2026 at 8:24 pm

    See the picker view delegate protocol. Implement this method:

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

    In here, you can get the appropriate value from the model and update your text field.

    To work out which is the current text field, you’d need to find out which of the text fields is the first responder.

    Have all of the text fields in an IBOutletCollection or array, iterate through them and find the one which is first responder.

    Or, if you have text field delegates, you can set an ivar for the current text field in the didBeginEditing delegate method, and use this in the picker view delegate method above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble figuring out exactly how to approach this problem and am
I'm having trouble figuring out a solution to this. I have several tables in
I'm having trouble figuring out how to exclude /public/bin from this rewrite rule RewriteCond
I'm having trouble figuring out how to implement the code from this answer. Android:
I'm having a bit of trouble figuring out what would be the best approach
Having trouble figuring out the syntax (which I'm sure is obvious and I'm stupid)
I having trouble figuring out the correct architecture for this kind of application: it's
I'm having a bit of trouble figuring out what's going wrong with this function.
I am having trouble figuring out how to implement this. I am returning user
I'm having trouble figuring out where I'm going wrong with this date formatting on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.