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 8617903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:58:52+00:00 2026-06-12T05:58:52+00:00

I have two UIPickerView and one UITextField in my search view. Everything was working

  • 0

I have two UIPickerView and one UITextField in my search view. Everything was working fine when I Input/Select the two UIPickerView first and then I input UITextField.

But when I change the order like Inputting UITextField then selecting UIPickerView, the problem happening is keyboard is not resigned when I tap on the UIPickerViews.

Below is my code

- (void) textFieldDidBeginEditing: (UITextField *) textField
//---------------------------------------------------------------
{
    if (textField == self.txtFieldPoetName) {
        NSLog(@"sdsdfsd");
      [textField resignFirstResponder];
      if ( [self.poetNameArray count] > 0 ){
          [self showPoetNamePicker];
      }

    }
    else if (textField == self.txtFieldPoemType) {
        NSLog(@"jdjdjdjd");
        [textField resignFirstResponder];

        if( [self.poemTypeArray count] > 0 ){
            [self showPoemTypePicker];
        }
    }
}


- (void) textFieldDidEndEditing:(UITextField *)textField{

    [textField resignFirstResponder];

}

- (void)showPoetNamePicker {

    [self resignKeyboard];

    startXMLParser_ = NO;

    self.actionSheet = [[[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]autorelease];
    self.actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    self.actionSheet.title = @"Poet Name";
    self.poetNamePicker = [[[UIPickerView alloc] init]autorelease];
    self.poetNamePicker.showsSelectionIndicator = YES;
    self.poetNamePicker.dataSource = self;
    self.poetNamePicker.delegate = self;
    PickerType = 1;

    //Set up the display frame
    self.poetNamePicker.frame = CGRectMake(0, 35, 320, 120);

    //Add the picker to the view
    [self.actionSheet addSubview:self.poetNamePicker];

    UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
    closeButton.momentary = YES; 
    closeButton.frame = CGRectMake(260, 6.0f, 50.0f, 27.0f);
    closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
    closeButton.tintColor = [UIColor blackColor];
    [closeButton addTarget:self action:@selector(hidePicker:) forControlEvents:UIControlEventValueChanged];
    [self.actionSheet addSubview:closeButton];
    [closeButton release];

    [self.actionSheet showInView:self.appDelegate.tabBarController.view];
    [self.actionSheet setBounds:CGRectMake(0, 0, 320, 385)];
}

- (void)showPoemTypePicker {

    [self resignKeyboard];

    startXMLParser_ = YES;

    self.actionSheet = [[[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]autorelease];
    self.actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    self.actionSheet.title = @"Poem Type";
    self.poemTypePicker = [[[UIPickerView alloc] init]autorelease];
    self.poemTypePicker.showsSelectionIndicator = YES;
    self.poemTypePicker.dataSource = self;
    self.poemTypePicker.delegate = self;
    PickerType = 2;

    //Set up the display frame
    self.poemTypePicker.frame = CGRectMake(0, 35, 320, 120);

    //Add the picker to the view
    [self.actionSheet addSubview:self.poemTypePicker];

    UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Done"]];
    closeButton.momentary = YES; 
    closeButton.frame = CGRectMake(260, 6.0f, 50.0f, 27.0f);
    closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
    closeButton.tintColor = [UIColor blackColor];
    [closeButton addTarget:self action:@selector(hidePicker:) forControlEvents:UIControlEventValueChanged];
    [self.actionSheet addSubview:closeButton];
    [closeButton release];

    [self.actionSheet showInView:self.appDelegate.tabBarController.view];
    [self.actionSheet setBounds:CGRectMake(0, 0, 320, 385)];
}

- (void)hidePicker:(id)sender
{

  if( PickerType == 1 )
  {
    if ( [self.poetNameArray count] > 0 &&
    [self.txtFieldPoetName.text length] == 0 )
    {
        //self.poemTypeId = @"";
      self.txtFieldPoetName.text = [self.poetNameArray objectAtIndex:0];
      self.poetTypeId = [self.poetTypeIdArray objectAtIndex:0];
    }
  }
  else if( PickerType == 2 )
  {
    if ( [self.poemTypeArray count] > 0  &&
    [self.txtFieldPoemType.text length] == 0)
    {
        //self.poetTypeId = @"";
      self.txtFieldPoemType.text = [self.poemTypeArray objectAtIndex:0];
      self.poemTypeId = [self.poemTypeIdArray objectAtIndex:0];

    }
  }

  [self resignFirstResponder];
  self.actionSheet.hidden = YES;
  [self.actionSheet dismissWithClickedButtonIndex:1 animated:YES];

  if (startXMLParser_)
  {
    [self performSelector:@selector(startXMLParsing) withObject:nil afterDelay:0.5];
  }
}

-(void)resignKeyboard{

    [self.txtFieldPoetName resignFirstResponder];
    [self.txtFieldPoemName resignFirstResponder];
    [self.txtFieldPoemType resignFirstResponder];

}
  • 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-12T05:58:54+00:00Added an answer on June 12, 2026 at 5:58 am

    EDIT :

    - (void) textFieldShouldBeginEditing: (UITextField *) textField
    {
       if (textField == self.txtFieldPoetName)
       {
          if( [self.poemNameArray count] > 0 ){
           [self showPoetNamePicker];
          }
          return NO;
       }
       else if (textField == self.txtFieldPoemType)
       {
         if( [self.poemTypeArray count] > 0 ){
            [self showPoemTypePicker];
         }
         return NO;
       }
       else
       {
         return YES;
       }
    }
    

    In showPoetNamePicker add this:

     - (void)showPoetNamePicker
     {
         [self.view endEditing:YES];
         ........
         ........
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes (MVC view model) which inherits from one abstract base class.
I am presently working with a uipickerview on a view. The picker has two
I have 3 UITexfield, the user can fill in the first two, but the
I have UIPickerView with two columns and in one column I want to display
I am working on a Poker-iPhone-Application. Everything works just fine but I would like
I have two UIPickerViews set up on one view under the same view controller.
I have a UIPickerView with two components. It works fine when the user scrolls
I have created two view controllers in XCode along with a UIPickerView, a label,
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
is it possible to handle two data sources in the UIPickerView? I have here

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.