0

Work around:

UIViewController contains UITableview with custom cell. Each cell contains cusom UIView with UITextField.

We all know that it is possible to manage UITextField delegates and make UIView up/down to show UITextField that are not visible when keyboard appears.

Problem:

Here content of UITableView is dynamic, its decided runtime that which cell contains UITextField. I have tried many solution for keyboard up/down views. But still some issues remains.

So now decided to make a translation only for that UITextField which are not appear on screen or behind the keyboard.

Is there any way to know that UITextField which is responder of keyboard appearance is behind the keyboard or its above the keyboard?

Any better approach?

Please add a comment if question is unclear.

Kampai
  • 22,848
  • 21
  • 95
  • 95
  • 1
    try this: http://stackoverflow.com/questions/15036519/scroll-uitextfield-above-keyboard-in-a-uitableviewcell-on-a-regular-uiviewcontro – Asif Mujteba Aug 05 '14 at 12:43

2 Answers2

1

Based on the current textField frame y position you can check is that is it behind the keyboard or not using

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

    CGPoint textFieldPosition = [textField convertPoint:CGPointZero toView:self.tableView];
}

now check the y value and move your UIVIew based on y value..

Retro
  • 3,985
  • 2
  • 17
  • 41
1

Instead of checking all this you can reframe the tableView when keyboard is visible.

In viewDidLoad() add this

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShow) name:UIKeyboardDidShowNotification object:nil];

in receiver set the new frame

 - (void)keyboardShow{
        [tableView setFrame:newFrame]
    }

again in name:UIKeyboardDidHideNotification reset to initial frame when keyboard is not there

Rajesh
  • 10,318
  • 16
  • 44
  • 64