Keyboard UITableViewController and UITextField

I have a UITableViewController with a grouped static UITableView. I define cells for my static table view on a storyboard. One of the cells has a text box. When this text field is called up, the keyboard appears, but the table view does not change automatically, as usual, on the table view controller. So, now the keyboard partially covers the text box, and I cannot scroll up.

I understand that when you use the UITableViewController and tableview, the viewport should automatically decrease when the keyboard is called. It works as intended in other parts of my application, just not with this static table view. Does it work with static tables? Is there anything else I am missing? Is there an easy way to solve this problem?

thank

+9
ios objective-c
Jul 03 2018-12-12T00:
source share
3 answers

Answer

This has nothing to do with static cells. They should work.

If your controller is already a UITableViewController, check if the viewWillAppear method is viewWillAppear . If you have done this, you need to call [super viewWillAppear:YES] to get "automatic behavior".

 -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:YES]; // This line is needed for the 'auto slide up' // Do other stuff } 

This problem easily arises because the template code for controllers does not come up with a call to the viewWillAppear method, and if you define it in your controller, you override it.

Additional Information

Take a look at this link.

Apple Table Programming Guide

Note. UITableViewController has new features in iOS 3.0. table-view controller supports built-in editing of table rows; if, for example, lines have embedded text fields in edit mode, this scrolls the line being edited over the virtual keyboard, which is displayed .... blah ....

Important bit

The UITableViewController class implements the previous behavior overload loadView, viewWillAppear: and other methods inherited from the UIViewController. In your subclass of UITableViewController, you can also override these methods to obtain specialized behavior. If you do this, override these methods, be sure to call the superclass the implementation of the method, usually like calling the first method, to get the default behavior.

+48
Jul 08 2018-12-12T00:
source share

For swift

 override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) } 
+1
Oct. 21 '14 at 2:59
source share

Pushes the view up if one of the table forms is selected for editing (implementation of the keyboard notification is required)

 - (void) keyboardDidShow:(NSNotification *)aNotification { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.25]; self.view.center = CGPointMake(self.view.center.x, self.view.center.y-moveAmount); [UIView commitAnimations]; isRaised = [NSNumber numberWithBool:YES]; } 

Resizes the table (divides the height by 2). Swap it on the keyboard to show the method. Alternatively, you can use the keyboard to hide the method to undo this stuff.

 CGRect temp = CGRectMake(mineTable.frame.origin.x, mineTable.frame.origin.y, mineTable.frame.size.width, mineTable.frame.size.height/2); mineTable.frame = temp; 
0
Jul 03 2018-12-12T00:
source share



All Articles