Why does UITextField start editing when the view controller is popped off the navigation stack?

I have a single UINavigationController with an arbitrary root view controller. Then I push the following subclassed UITableViewController onto the navigator stack:

@interface BugViewController : UITableViewController <UITextFieldDelegate>

@end

@implementation BugViewController

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc] init];

    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 0, 200, 30)];
    [textField setBackgroundColor:[UIColor yellowColor]];
    [textField setDelegate:self];

    [[cell contentView] addSubview:textField];
    return cell;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    NSLog(@"did begin editing");
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
    NSLog(@"did end editing");
}

@end

      

Basically, it's just a single line UITableViewController that contains a single UITextField.

Repro Steps:

  • Click the text box
    • "edit started" is logged as expected
  • Click "<Back" in the navigation bar
    • "complete edit" is logged as expected
    • "editing started" and "editing finished" are registered again ( unexpectedly !)

I'm trying to figure out why a textbox starts and then edits end again during a reverse animation.

Note that I can prevent this behavior by overriding viewWillDisappear:animated:

and calling resignFirstResponder

in the textbox, but I still don't understand the underlying problem.

+3
ios objective-c ios7 first-responder uinavigationcontroller


source to share


No one has answered this question yet

Check out similar questions:

1665
How can I get the UITextField to move upward when there is a keyboard - when starting editing?
4
The first click on the second UITextfield located inside the tableviewcell did not start with editing (display cursor). Only the second tap is working. What for?
2
UITextField background change while edit starts for multiple fields
1
Get item position
1
UIPickerView not showing as inputview when UITextField starts editing
1
Placeholders appear when scrolling uitextField out of sight - ios
0
Changing focus between UITextFields in cells in the same UITableView
0
iOS animates partial cells to show full cell
0
Keyboard control when entering text into UITableView cells containing UITextFields
-1
Scrolling UITableView with embedded UITextField



All Articles
Loading...
X
Show
Funny
Dev
Pics