इसलिए मैंने कीबोर्ड उपस्थिति ईवेंट के लिए एक अधिसूचना स्थापित की है। अब हम एक UITextView और एक UITextField पर विचार करें।यूआईटीएक्स्टफिल्ड और कीबोर्ड नोटिफिकेशन - अजीब ऑर्डर
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
चयनकर्ता है:
- (void)keyboardWillShow:(NSNotification *)notification {
keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
}
एक UITextView के मामले में, प्रतिनिधि विधि - (void)textViewDidBeginEditing:(UITextView *)textView
keyboardWillShow:
विधि के बाद निकाल दिया जाता है। तो कीबोर्ड आकार में कीबोर्ड का वास्तविक आकार होता है और मैं इसे टेक्स्टव्यू प्रतिनिधि विधि के अंदर उपयोग करने में सक्षम हूं।
हालांकि एक UITextField के मामले में, इसी प्रतिनिधि विधि - (void)textFieldDidBeginEditing:(UITextField *)textField
keyboardWillShow:
विधि से पहले निकाल दिया गया है।
ऐसा क्यों है? मैं कैसे कीबोर्ड की CGSize
पाठ फ़ील्ड के मामले में के रूप में अब यह सिर्फ शून्य क्योंकि पाठ फ़ील्ड प्रतिनिधि पहले कहा जाता है और नहीं कुंजीपटल चयनकर्ता रिटर्न मिलता है।
मेरे मामले में सरल dispatch_async (mainQueue,^{}) ने मदद की। – Andy