UIView moving up with the keyboard shown

I know this is a frequent question, but ive was not lucky to implement this from the examples I found. I could do something simple wrong (let's hope so). I am trying to move the UIview up as I have a text box hidden below.

A little about my application, it got a tab bar controller and implements a standard UIView. When I add code to move the display, nothing happens. Do I need to have scroll for this to work, is this a conflict with the tab controller, or am I doing something else wrong? thank

Dan

+3
source share
2 answers

UIView, , UIScrollView. "" , , , , , - UIView ( UIView).

, , , .

UIView + FormScroll.h:

#import <Foundation/Foundation.h>

@interface UIView (FormScroll) 

-(void)scrollToY:(float)y;
-(void)scrollToView:(UIView *)view;
-(void)scrollElement:(UIView *)view toPoint:(float)y;

@end

UIView + FormScroll.m:

#import "UIView+FormScroll.h"


@implementation UIView (FormScroll)


-(void)scrollToY:(float)y
{

    [UIView beginAnimations:@"registerScroll" context:NULL];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.4];
    self.transform = CGAffineTransformMakeTranslation(0, y);
    [UIView commitAnimations];

}

-(void)scrollToView:(UIView *)view
{
    CGRect theFrame = view.frame;
    float y = theFrame.origin.y - 15;
    y -= (y/1.7);
    [self scrollToY:-y];
}


-(void)scrollElement:(UIView *)view toPoint:(float)y
{
    CGRect theFrame = view.frame;
    float orig_y = theFrame.origin.y;
    float diff = y - orig_y;
    if (diff < 0) {
        [self scrollToY:diff];
    }
    else {
        [self scrollToY:0];
    }

}

@end

UIViewController,

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    [self.view scrollToView:textField];
}

-(void) textFieldDidEndEditing:(UITextField *)textField
{
    [self.view scrollToY:0];
    [textField resignFirstResponder];
}

... . .

+6

- UITableViewCell UITableView. UITableView , Apple. , , .

UITableView, . , . UITableView.

+1

All Articles