iPhone控制鍵盤

2021-08-31 17:00:59 字數 1446 閱讀 1108

有時候當鍵盤彈出時會把輸入框蓋住,這時候我們就沒法看到自己到底輸入的是什麼了,這時候我們就需要註冊兩個事件,那就是在鍵盤顯示的時候 把輸入框的位置放在可見的地方 ,當關閉鍵盤時,在將輸入框還原,以下就是解決問題的具體方法,我們只要註冊就可以了

// call this method somewhere in your view controller setup code.

- (void)registerforkeyboardnotifications

[[nsnotificationcenter defaultcenter] removeobserver:self 

name:uikeyboarddidshownotification 

object:nil];

[[nsnotificationcenter defaultcenter] removeobserver:self 

name:uikeyboarddidhidenotification 

object:nil];

[[nsnotificationcenter defaultcenter] addobserver:self

selector:@selector(keyboardwasshown:)

name:uikeyboarddidshownotification object:nil];

[[nsnotificationcenter defaultcenter] addobserver:self

selector:@selector(keyboardwashidden:)

name:uikeyboarddidhidenotification object:nil];

// called when the uikeyboarddidshownotification is sent.

- (void)keyboardwasshown:(nsnotification*)anotification

self.frame = cgrectmake(0, -90, 320, 480);

// called when the uikeyboarddidhidenotification is sent

- (void)keyboardwashidden:(nsnotification*)anotification

self.frame = cgrectmake(0, 20 , 320, 460);

[[nsnotificationcenter defaultcenter] removeobserver:self 

name:uikeyboarddidshownotification 

object:nil];

[[nsnotificationcenter defaultcenter] removeobserver:self 

name:uikeyboarddidhidenotification 

object:nil];

控制鍵盤的輸入

1 新建乙個工具類 import class keyboardtool typedefenum keyboardtoolbuttontype pragma mark 定義協議 protocol keyboardtooldelegate void keyboardtool keyboardtool k...

CEdit 控制鍵盤操作

寫在前面的話 在工作中要實現這樣乙個功能,在乙個樹形控制項中選擇要傳送訊息的客戶,新增到乙個列表控制項中,點選確定跳到乙個資訊傳送頁面如下圖,在傳送人編輯框中顯示選擇的客戶,要實現的就是即允許使用者刪除使用者列表中的使用者,但是又不能讓使用者只刪除乙個使用者標識的一部分,所以要對鍵盤操作進行控制。實...

十八 用GUI自動化控制鍵盤和滑鼠

關於 python程式設計快速上手 讓繁瑣工作自動化 的學習筆記 windows上使用pip install pyautogui安裝 import pyautogui pyautogui.pause 1 pyautogui.failsafe true這裡匯入pyautogui並將pyautogui....