Keyboard adjustment in UIScrollview
Post date: Dec 16, 2013 9:41:14 AM
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self becomeFirstResponder];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(MoveTheViewDownside:) name:UIKeyboardWillHideNotification object:nil];
}
- (void) textFieldDidBeginEditing:(UITextField *)textField
{
UIScrollView *properScrollView = (UIScrollView*)[textField superview];
[self scrollProperScroll:properScrollView toView:textField];
}
- (void) scrollProperScroll:(UIScrollView*)aScrollView toView:(id)aView
{
_scrollViewOffset = aScrollView.contentOffset;
CGPoint pt;
CGRect rc = [aView bounds];
rc = [aView convertRect:rc toView:aScrollView];
pt = rc.origin;
pt.x = 0;
pt.y -= 60;
[aScrollView setContentOffset:pt animated:YES];
}
-(void)MoveTheViewDownside:(NSNotification *) notification
{
[_leftProfileView setContentOffset:CGPointMake(0,0) animated:YES];
}