Friday 28 September 2012

UIKeyBoard SplitView mode notification in iPAD

NSNotificationCenter is used to find the UIKeyBoard show or hide notification. From iOS5 can get the keyboard change notification (UIKeyboardDidChangeFrameNotification). Normally UIKeyboard have three modes are
 

  •        Dock
  •        UnDock
  •        Split


 Can find the keyboard show or hide notification by using name UIKeyboardWillHideNotification and UIKeyboardDidShowNotification for DOCK and UNDOCK mode.
In the split view, have to use UIKeyboardDidChangeFrameNotification to find the keyboard showor hide notification.


Register the notification in your  view controller to find keyboard changes in split view mode


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

NSString *version = [[UIDevice currentDevice] systemVersion]; 
    float version_float = [version floatValue];

        if( version_float > 5.0])  //use notification if system version iOS5 and above
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShoworHide:) name:UIKeyboardDidChangeFrameNotification object:nil];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil]; 


In the keyboardWillShoworHide method implementation have to check for the keyboard showing or hiding

BOOL wasKeyboardVisible;
- (void) keyboardWillShoworHide:(NSNotification *)aNotification
{
    NSDictionary* info = [aNotification userInfo];
    
    CGRect currentKbRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    
    BOOL keyboardVisible = CGRectIntersectsRect(currentKbRect, screenRect);
    
    if (keyboardVisible && !wasKeyboardVisible) {
        
     //keyboard visible
        
    } else if (!keyboardVisible && wasKeyboardVisible) {
    //keyboard hidden
    }
  
    wasKeyboardVisible = keyboardVisible;
   
}


11 comments:

  1. Hello my friend! I would like to tell you that this write-up is awesome, great written and include almost all important info. I would like to see a lot more articles like this.
    ios application development

    ReplyDelete
  2. It's really informative! Thanks for the great article.
    At Hvantage Technologies, we are dedicated to providing online solutions: Web design & development, e-commerce solution, web promotion/SEO (search engine optimization ) and website maintenance services for your business. more details you should visit here once: www.hvantagetechnologies.com

    ReplyDelete
  3. Thankyou! Very well written article.
    Yberry Infosystem is a professional IT Development Company in India offering Mobile Application Development,Web Application Development. Ecommerce services, branding designing, graphics design as well as SEO solutions. Visit: www.yberryinfosystem.com

    ReplyDelete
  4. Nice Article! Codevian Technologies is a professional PHP development company. We provide our services and best results to our customers. We bring great websites and web application of every size to our clients. We transform your dream projects into reality. Codevian Technologies is the right place to hire php developers. Please feel free to call us on +91 9225108952 or contact by email at sales@codevian.com, if you require any additional information. Please visit our website www.codevian.com.com

    ReplyDelete
  5. Excellent article,We provide many many imformation about Dubrin labs limited is one of the proud members of Bangladesh Association of Software and Information Services (BASIS). We develop enterprise grade software and IT solution or organization all around the globe. We build android, iOS, Cross platform, and web application. Durbin labs limited has a reputation as one of the innovative firm for software development in Bangladesh.
    More info you can vist Android App development
    Thanks for sharing such beautiful information with us

    ReplyDelete
  6. Hey this one is a very nice article and its is going to help the audience a lot and will help them with the knowledge of Android application development services and will also enlighten them with the knowledge of the same. If you want one of the Best Android application development services online in Greater Noida then Softgains is the place you should go for

    ReplyDelete
  7. This blog is really unique and informative. I really get amazed to read this.BlockChain & CryptoCirrencies Development

    ReplyDelete
  8. An interesting article that discusses about UIKeyBoard SplitView mode notification in iPAD. Thanks for sharing.

    Vicky from Way2Smile Solutions DMCC - Trusted iPhone App Development Company in Dubai

    ReplyDelete
  9. Nice article and it’s really helpful content for us, keep sharing like this more informational article. If you a looking Leading Mobile App Development Company in Delhi NCR. Visit: Mobile App Development Company

    ReplyDelete