Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [_nameTextField becomeFirstResponder];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillBeHidden:) name:UIKeyboardWillHideNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardWillShowNotification object:nil];
- }
- -(void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
- [[NSNotificationCenter defaultCenter] removeObserver:UIKeyboardWillHideNotification];
- [[NSNotificationCenter defaultCenter] removeObserver:UIKeyboardWillShowNotification];
- }
- #pragma mark - TextField Delegate
- - (BOOL)textFieldShouldReturn:(UITextField *)textField {
- if (textField == _nameTextField) [_emailTextField becomeFirstResponder];
- else if (textField == _emailTextField) {
- [_passwordTextField becomeFirstResponder];
- }
- else if (textField == _passwordTextField) {
- self.tableView.contentInset = UIEdgeInsetsZero;
- NSLog(@"AHO");
- // return YES;
- }
- return YES;
- }
- - (void)keyboardWasShown:(NSNotification*)notification {
- NSDictionary* info = [notification userInfo];
- CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
- // Andiamo ad ottenere la giusta altezza della tastiera calcolando anche il bottom per iPhoneX quando si utilizza SafeAreaInset
- // Nel caso in cui la tastiera ha un'altezza pari a Zero non compiere nessuna azione diversamente mostra il pannello del login
- if (kbSize.height == 0) return;
- else {
- UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, 40, 0.0);
- self.tableView.contentInset = contentInsets;
- }
- }
- -(void)keyboardWillBeHidden:(NSNotification *)notification {
- self.tableView.contentInset = UIEdgeInsetsZero;
- }
Add Comment
Please, Sign In to add comment