开发者

show the keyboard of a textfield on top of the screen

开发者 https://www.devze.com 2023-01-09 18:33 出处:网络
In my iPhone apps, my problem is that I have a textfie开发者_运维知识库ld at the bottom of the screen, so when the keyboard appear, he hides the textfied, there is a way to show the keyboard on the to

In my iPhone apps, my problem is that I have a textfie开发者_运维知识库ld at the bottom of the screen, so when the keyboard appear, he hides the textfied, there is a way to show the keyboard on the top of the screen?


You should move your view when the keyboard appears. The code is:

In .m file

- (void) loginViewUp : (UIView*) view
{   
    if(!alreadyViewUp)
    {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];
        CGRect rect = view.frame;
        rect.origin.y -= View_Move_Hight;
        view.frame = rect;
        [UIView commitAnimations];
        alreadyViewUp = !alreadyViewUp;
    }
}

- (void) loginViewDown :(UIView*) view
{        
    if(alreadyViewUp)
    {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];
        CGRect rect = view.frame;
        rect.origin.y += View_Move_Hight;
        view.frame = rect;
        [UIView commitAnimations];
        alreadyViewUp = !alreadyViewUp;
    }
}

In .h file

- (void) loginViewUp : (UIView*) view;

here

#define View_Move_Hight 170 

is defined before @implementation.


You should design your view so that it shifts up with the keyboard, iPhone users are used to the keyboard always being on the bottom of the screen so this would go against the HIG

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号