簡體   English   中英

在屏幕頂部顯示文本字段的鍵盤

[英]show the keyboard of a textfield on top of the screen

在我的iPhone應用程序中,我的問題是我在屏幕底部有一個文本字段,所以當鍵盤出現時,他隱藏了文本,有一種方法可以在屏幕頂部顯示鍵盤?

鍵盤出現時應移動視圖。 代碼是:

在.m文件中

- (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;
    }
}

在.h文件中

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

這里

#define View_Move_Hight 170 

@implementation之前@implementation

你應該設計你的視圖,以便它通過鍵盤向上移動,iPhone用戶習慣於鍵盤總是在屏幕的底部,所以這將違背HIG

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM