I am having a textfield which is having the hierarchy as
self.view->Tableview->contentview->anotherview->MyTextfield.
I want to get y position of MyTextField with reference of self.view.
My requirement:
Whenever I click on textfield, I am opening my keyboard, if the textfield is under my keyboard (which I will be checking by comparing the frame of MyTextField
with reference of self.view
) then I will be changing the frame of my cell otherwise (if MyTextField
is not under my keyboard) then I dont need to change the frame.
I am trying to use the following method, but dont know how to exactly implement this.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
UIView *aView = textField.superview.superview.superview.superview.superview.superview.superview;
NSLog(@"%@",[aView class]);
CGRect textFieldRect = [textField convertRect:textField.frame fromView:aView];
NSLog(@"View: %@",NSStringFromCGRect(textFieldRect));
return YES;
}