Iam trying to set scrolling for textfield based on indexpath in uitableview, for this I have written my code in following manner
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
- (void)keyboardWillShow:(NSNotification *)sender
{
CGSize kbSize = [[[sender userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
NSTimeInterval duration = [[[sender userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^
{
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(0, 0, kbSize.height, 0);
[self.mytableview setContentInset:edgeInsets];
[self.mytableview setScrollIndicatorInsets:edgeInsets];
}];
}
- (void)keyboardWillHide:(NSNotification *)sender
{
NSTimeInterval duration = [[[sender userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
[UIView animateWithDuration:duration animations:^
{
UIEdgeInsets edgeInsets = UIEdgeInsetsZero;
[self.mytableview setContentInset:edgeInsets];
[self.mytableview setScrollIndicatorInsets:edgeInsets];
self.mytableview.contentOffset = CGPointMake(0,0);
}];
}
By adding all those coding my textfields scrolling are working fine in Iphone 5(Retina 4 Inch) Device, but its not working Iphone 4 Device(Retina 3.5 Inch).
Note:Iam not Using autolayout ,Based on storyBoards i was working on different devices.
Can Anyone please give some helpful informaton. Thanks in Advance
0 comments:
Post a Comment