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

  • SEARCH
  • Home
  • 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 8217731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:33:12+00:00 2026-06-07T12:33:12+00:00

I am using the inputView to display a pickerView when a a textfield is

  • 0

I am using the inputView to display a pickerView when a a textfield is clicked. I then want to populate the pickerview with the numbers 1-100. I have some code that I thought would work, but when i run the program and click on the textField, it just pops up an empty pickerview. Also need to know how to put another button on the toolbar. I would like to have a submit button on the right side to confirm the users selection (going to change the done to cancel) Is there something I have to do in the interface builder with the picker and buttons? because i don’t actually have those in the interface builder because they are made with code…

Below are my .h and .m files.

.h—-

@interface TestinputviewViewController : UIViewController <UITextFieldDelegate,UIPickerViewDataSource,UIPickerViewDelegate> {

IBOutlet UITextField *textField;
NSMutableArray *pickerViewArray;
}
-(IBAction) textFieldDidBeginEditing;
@end

.m—

 #import "TestinputviewViewController.h"

@implementation TestinputviewViewController


-(IBAction)textFieldDidBeginEditing{


UIPickerView *myPickerView = [[UIPickerView alloc] init];
textField.inputView = myPickerView;
myPickerView.showsSelectionIndicator = YES;
myPickerView.delegate = self;
myPickerView.dataSource = self;
    [myPickerView release];


UIToolbar *myToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,0,320,44)];
                        UIBarButtonItem *doneButton =     [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self   action:@selector(inputAccessoryViewDidFinish)];
[myToolbar setItems:[NSArray arrayWithObject:doneButton] animated:NO];
                        textField.inputAccessoryView =     myToolbar; 

}   



-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)myPickerView {
return 1;
}

-(NSInteger)pickerView:(UIPickerView *) myPickerView numberOfRowsInComponent: (NSInteger)component {
return [pickerViewArray count];
}

-(NSString *)pikerView:(UIPickerView *) myPickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [pickerViewArray objectAtIndex:row];
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a     nib.
- (void)viewDidLoad {
[super viewDidLoad];

pickerViewArray = [[NSMutableArray alloc] init];
for (int i = 1; i<=20; i++) {
    NSString *myString = [NSString stringWithFormat:@"%d%",i];
    [pickerViewArray addObject:myString];

}
}
  • 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-06-07T12:33:13+00:00Added an answer on June 7, 2026 at 12:33 pm

    You are not setting delegate of picker to the current object class.

    use

    `myPickerView.delegate = self;`
    
     `myPickerView.dataSource = self;`
    

    after allocating the picker view object.

    go on..

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

Sidebar

Related Questions

I have two fields that call UIPickerView (Country and Province). I'm using inputView to
Using MVVM. I have a DataTemplate which I am using to display an expander
Using report builder 3.0, I have a report that queries a cube. How do
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
Using restlet, I want to make a post to android's c2dm service. I have
I have decided that I wanted to create some custom dialog classes that could
Using CRM 4, I have an entity form that contains a tab with an
Using a populated Table Type as the source for a TSQL-Merge. I want to
Using CodeIgniter, how do I access and display text entered into an input field
I am using storyboards and have dragged a scrollview window onto a view. In

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.