久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

顯示 iphone 的鍵盤時調整 UIView 的大小,如何?

resize UIView when showing the keyboard for iphone, how to?(顯示 iphone 的鍵盤時調整 UIView 的大小,如何?)
本文介紹了顯示 iphone 的鍵盤時調整 UIView 的大小,如何?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我將向您展示一個眾所周知的 whatsapp 示例當您觸摸文本內部時,鍵盤會彈出,因此我必須向上移動或移動所有條并將視圖大小調整為一半,這樣我仍然可以看到我正在輸入的文本和發送按鈕

I will show you an example with the well known whatsapp When you touch inside the text the keyboard pops up , so I have to move or shift all that bar up and resize the view to half, so I can still see the text that I'm typing and the send button

第一階段:http://www.appbank.net/wp-content/uploads/2010/10/WhatsAppMessenger-18.jpg

第二階段:http://www.onetooneglobal.com/wp-content/uploads/2011/02/onetoone_whatsapp_2.png

實現這一目標的最佳方法是什么?

What would be the best way to achieve this?

推薦答案



#define kOFFSET_FOR_KEYBOARD 280.0

- (void)keyboardWillHide:(NSNotification *)notif {
    [self setViewMoveUp:NO];
}


- (void)keyboardWillShow:(NSNotification *)notif{
    [self setViewMoveUp:YES];
}


- (void)textFieldDidBeginEditing:(UITextField *)textField {
    stayup = YES;
    [self setViewMoveUp:YES];
}


- (void)textFieldDidEndEditing:(UITextField *)textField {
    stayup = NO;
    [self setViewMoveUp:NO];
}

//method to move the view up/down whenever the keyboard is shown/dismissed
-(void)setViewMoveUp:(BOOL)moveUp
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3]; // if you want to slide up the view
    [UIView setAnimationBeginsFromCurrentState:YES];

    CGRect rect = self.view.frame;
    if (moveUp)
    {
        // 1. move the view's origin up so that the text field that will be hidden come above the keyboard 
        // 2. increase the size of the view so that the area behind the keyboard is covered up.

        if (rect.origin.y == 0 ) {
            rect.origin.y -= kOFFSET_FOR_KEYBOARD;
            //rect.size.height += kOFFSET_FOR_KEYBOARD;
        }

    }
    else
    {
        if (stayup == NO) {
            rect.origin.y += kOFFSET_FOR_KEYBOARD;
            //rect.size.height -= kOFFSET_FOR_KEYBOARD;
        }
    }
    self.view.frame = rect; 
    [UIView commitAnimations];
}

試試這個方法.根據您的要求對其進行編輯.

Try this methods. Edit it according to your requirement.

這篇關于顯示 iphone 的鍵盤時調整 UIView 的大小,如何?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Find the CGPoint on a UIView rectangle intersected by a straight line at a given angle from the center point(在與中心點成給定角度的直線相交的 UIView 矩形上找到 CGPoint)
Is it possible to reference a variable with a string and an int?(是否可以使用字符串和 int 引用變量?)
Is there a native YAML library for iPhone?(是否有適用于 iPhone 的本機 YAML 庫?)
View aligned to top of keyboard appears in wrong place in iOS 9 Shortcut Bar only mode(在 iOS 9 Shortcut Bar only 模式下,與鍵盤頂部對齊的視圖出現在錯誤的位置)
Disable speech to text button (Micro phone) on soft input keyboard in android programmatically(以編程方式在android中的軟輸入鍵盤上禁用語音到文本按鈕(麥克風))
UIkeyboard type(UI鍵盤類型)
主站蜘蛛池模板: 在线精品国产 | 久久www免费人成看片高清 | 福利片在线观看 | 日本亚洲欧美 | a在线观看 | av在线播放网站 | 蜜桃av鲁一鲁一鲁一鲁 | 中文字幕一区二区三区不卡 | 国产一区二区三区久久久久久久久 | 国产大片一区 | 亚洲黄色成人网 | 99re视频| 一区亚洲| 亚洲成人精品 | 国产成人综合一区二区三区 | 国产成人高清在线观看 | 看一级毛片视频 | 中文久久 | 97影院在线午夜 | 欧美日韩视频一区二区 | 国产精品影视在线观看 | 亚洲国产成人精品女人久久久野战 | 天天爽夜夜操 | av网站免费| 99欧美精品 | 国产成在线观看免费视频 | 欧美激情一区二区三区 | 男女羞羞免费视频 | 精品一区二区三区在线观看 | 亚洲国产精品久久久久婷婷老年 | 久久小视频 | 啪啪综合网 | 黄色一级大片在线免费看产 | 亚洲久久 | 黑人一级黄色大片 | 精品一区二区观看 | 欧美亚洲视频 | 久草色视频 | 伊人久久综合影院 | 日韩欧美视频在线 | 成人免费视频网站在线看 |