2010-10-04 16 views
7

के बाद आईपैड ऑन-स्क्रीन कीबोर्ड का आकार प्राप्त करना एक ऐप के लिए मैं आईपैड के लिए डिज़ाइन कर रहा हूं, मेरे पास कुछ टेक्स्ट फ़ील्ड्स/टेक्स्ट व्यू के साथ एक स्क्रॉल व्यू है। सबकुछ दृश्यमान रखने के लिए, मैं स्क्रॉल दृश्य की contentSize संपत्ति को नीचे बफर जोड़ने के लिए समायोजित करता हूं जो कुंजीपटल स्क्रॉल व्यू को ओवरलैप करता है। कोड यह (वहाँ कुछ ऐप्स-विशिष्ट सामग्री यहां मौजूद नहीं इतना है कि आप इसे का मतलब नहीं कर सकते है, लेकिन उम्मीद है कि):रोटेशन

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 

    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 
    [nc addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 
    [nc addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; 
} 


- (void)viewWillDisappear:(BOOL)animated 
{ 
    [super viewWillDisappear:animated]; 

    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 
    [nc removeObserver:self name:nil object:nil]; 
} 

- (void)keyboardWillShow:(NSNotification *)aNotification 
{ 
    NSValue *animationCurve = [[aNotification userInfo] valueForKey:UIKeyboardAnimationCurveUserInfoKey]; 
    UIViewAnimationCurve curve; 
    [animationCurve getValue:&curve]; 

    NSValue *animationDuration = [[aNotification userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey]; 
    NSTimeInterval duration; 
    [animationDuration getValue:&duration]; 

    NSValue *endingFrame = [[aNotification userInfo] valueForKey:UIKeyboardFrameEndUserInfoKey]; 
    CGRect frame; 
    [endingFrame getValue:&frame]; 

    [UIView beginAnimations:@"keyboardWillShow" context:bodyView]; 
    [UIView setAnimationCurve:curve]; 
    [UIView setAnimationDuration:duration]; 

    // Re-draw code here. 

    [UIView commitAnimations]; 
} 

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

    NSValue *animationCurve = [[aNotification userInfo] valueForKey:UIKeyboardAnimationCurveUserInfoKey]; 
    UIViewAnimationCurve curve; 
    [animationCurve getValue:&curve]; 

    NSValue *animationDuration = [[aNotification userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey]; 
    NSTimeInterval duration; 
    [animationDuration getValue:&duration]; 

    [UIView beginAnimations:@"keyboardWillHide" context:bodyView]; 
    [UIView setAnimationCurve:curve]; 
    [UIView setAnimationDuration:duration]; 

    // Re-draw code here 

    [UIView commitAnimations];  
} 

मेरा प्रश्न यह है: मैं रोटेशन के दौरान कुंजीपटल आकार के बारे में क्या करते हैं? आईपैड घुमाए जाने पर मुझे कोई कीबोर्ड नोटिफिकेशन नहीं मिलता है, लेकिन कीबोर्ड का आकार महत्वपूर्ण रूप से बदलता है। आदर्श रूप से मैं कीबोर्ड को लैंडस्केप मोड में ओवरलैप की मात्रा से contentSize संपत्ति की ऊंचाई समायोजित करता हूं, लेकिन मुझे ऐसा करने का एक अच्छा तरीका नहीं दिख रहा है, जो कि दोनों ओरिएंटेशन में कीबोर्ड की ऊंचाई को कड़ी मेहनत किए बिना, नहीं करना चाहता

उत्तर

16

मुझे गलती से इस डिबगिंग का जवाब कुछ और मिला। यह पता चला है कि जब आईपैड पोर्ट्रेट से लैंडस्केप तक घूमता है, तो लैंडस्केप कीबोर्ड दिखाई देने से ठीक पहले पोर्ट्रेट कीबोर्ड छुपाता है (और इसकी सूचना भेजता है) (और भेजता है अधिसूचना)। तो जब तक आप इसके लिए खाते हैं, तो आप ठीक हैं।

संबंधित मुद्दे