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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:34:54+00:00 2026-06-05T07:34:54+00:00

I am trying to implement previous, next, and done buttons for a series of

  • 0

I am trying to implement “previous,” “next,” and “done” buttons for a series of UITextFields, each of which is contained in a UITableViewCell in a grouped UITableView. I hold on to the UITextFields in an NSMutableArray, and keep an integer pointing to the UITextField that is currently active. Here are the two selectors that get fired when the Previous and Next buttons are tapped, respectively.

-(IBAction)didSelectPreviousButton:(id)sender
{    
    if ((textFieldIndex - 1) >= 0) {
        UITextField *currentField = [self.testTextFields objectAtIndex:(textFieldIndex)];
        UITextField *nextTextField = [self.testTextFields objectAtIndex:(--textFieldIndex)];
        BOOL result = [nextTextField becomeFirstResponder];
        NSLog([NSString stringWithFormat:@"currentField's window: %@", currentField.window]);
        NSLog([NSString stringWithFormat:@"nextTextField's window: %@", nextTextField.window]);
    } else {
        [self dismissKeyboard:sender];
    }
}

-(IBAction)didSelectNextButton:(id)sender
{
    if ((textFieldIndex + 1) < [self.inspectionItemSpec.numberOfTests intValue]) {
        UITextField *currentField = [self.testTextFields objectAtIndex:(textFieldIndex)];
        UITextField *nextTextField = [self.testTextFields objectAtIndex:(++textFieldIndex)];
        BOOL result = [nextTextField becomeFirstResponder];
        NSLog([NSString stringWithFormat:@"currentField's window: %@", currentField.window]);
        NSLog([NSString stringWithFormat:@"nextTextField's window: %@", nextTextField.window]);
    } else {
        [self dismissKeyboard:sender];
    }
}

As you can see, I am logging the window property of the current & next text field, and in the didSelectNextButton, everything is correct. However, in didSelectPreviousButton, nextTextField.window is always nil. Why would this be happening?

(Note that the previous button is enabled only after the user has tapped the next button once.)

  • 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-05T07:34:58+00:00Added an answer on June 5, 2026 at 7:34 am

    This may be because each UITextField is in a UITableViewCell while also being referenced in self.testTextFields. Because of the way cells are re-used by tables in iOS, you could (and probably will) end up in a situation where the next text field in your array is not the text field in the next visible row in the table.

    If you post your tableView:cellForRowAtIndexPath: code, that may make the problem apparent.

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

Sidebar

Related Questions

Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
While trying to implement the second answer to a previous question , I am
Hi I am trying to implement Photos.app like application, in which on the below
I'm trying to implement pagination in a custom WP-Query. The pagination is done correctly,
I am trying to implement a slide down for table rows using the previous
I'm trying to implement a front end for a reporting solution which is security
I am trying to implement the previous page functionality for pagination, and I thought
I am trying to implement content browsing like it is done on Facebook when
Trying to implement a rating system of users and postings. What is the best
While trying to implement an MVC file upload example on Scott Hanselman's blog. I

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.