ios 動態監聽鍵盤輸入法和高度

    //監聽鍵盤高度變化

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasChange:) name:UIKeyboardDidChangeFrameNotification object:nil];


    

- (void)keyboardWasChange:(NSNotification *)aNotification {

    NSLog(@"Keyboard change");

    NSString *str=[[UITextInputMode currentInputMode] primaryLanguage];

    NSLog(@"shurufa--------------%@",str);

//    if ([str isEqualToString:@"zh-Hans"]) {

//        ReplayView.frame = CGRectMake(0, HEIGHT.height-216-125, 320, 45);

//    }else

//    {

//        ReplayView.frame = CGRectMake(0, HEIGHT.height-216-89, 320, 45);

//

//    

//    }

    

    

    NSDictionary *info = [aNotification userInfo];

    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;

   // CGRect frame = self.search.frame;

    if (kbSize.height == 216) {

        NSLog(@"english");

        ReplayView.frame = CGRectMake(0, HEIGHT.height-216-89, 320, 45);

    }

    else if(kbSize.height == 252){

        NSLog(@"中文");

        

        ReplayView.frame = CGRectMake(0, HEIGHT.height-216-125, 320, 45);

    }


}

發佈了79 篇原創文章 · 獲贊 74 · 訪問量 61萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章