RulTech - Pravin Dodia

Pravin Dodia

The keyboard is present in nearly every application out there. Using the keyboard is the easiest way to provide users with a way to input alphanumeric data into applications. Trivial as it might look like in the beginning, a correct implementation of keyboard behavior can be a costly endeavor. Multiple keyboard states make it hard to implement logic that will behave correctly for all of them.

This post will cover my observations and experiences with the keyboard system in iOS. I will try to describe some basic concepts behind the keyboard notification system and take a closer look at the order in which notifications are sent.

Keyboard System

There are two main patterns across the Objective-C/Cocoa framework that give the user an idea of how the communication process between different objects functions – the delegation pattern and the notifications pattern.

The public keyboard API is built around the latter. You just inform the NSNotificationCenterobject that you want to receive some specific notifications. These notifications are later sent to you from somewhere else within the application when a specific type of event occurs.

Given that notifications are a generic pattern, there has to be a way to utilize them so they provide as much information as we want them to. Moreover, this information can be represented by a different number of objects which can, in turn, represent various types. For this particular purpose there is auserInfo property in the NSNotification class. This dictionary provides the elements listening for notifications with an additional context behind the triggering of the notification.

For keyboard notifications, we use the [NSNotificationCenter defaultCenter] method to get an instance of NSNotificationCenter class, which will be used for the notification’s registration process.

And that’s all you need to start receiving notifications about the appearance of the keyboard. Well, what next?

Keyboard’s Notification

To put things bluntly, the iOS keyboard can be very annoying. Despite being really simple from the user’s perspective, in multiple cases the logic of the application suffers from either the lack or the misinterpretation of the system’s notifications. Below is a list of the keyboard’s notifications present in iOS:

UIKeyboardWillShowNotification – notification sent when the keyboard is about to show.

UIKeyboardDidShowNotification – notification sent when the keyboard is about to hide.

UIKeyboardDidShowNotificationUIKeyboardWillHideNotification – notification sent when the keyboard has just been hidden.

UIKeyboardWillChangeFrameNotification - notification sent when the kebyoard’s frame is about to change.

UIKeyboardDidChangeFrameNotification – notification sent when the keyboard’s frame has just changed.

If we take a look at the names of keyboard’s notifications it is pretty easy to think that the typical (maybe the only correct) ‘path’ for these notifications looks like.In fact, these two are the most common, but when defining your application logic you can’t always expect to get all these notifications in the presented order. It is entirely normal not to get some of them in specific circumstances or to get them in a different order. Since we want our applications to provide the best user experience possible, we should know about every possible order that they may have to deal with.

UserInfo Dictionary

The UserInfo property of the NSNotification class is the only (public) way to get the keyboard frame and some specific information about the keyboard’s animation. Every notification gives the developer a snapshot of the keyboard’s present or future state and allows us to update the state of the application. These are the properties of a userInfo dictionary which are passed with every keyboard notification:

UIKeyboardFrameBeginUserInfoKey – frame of the keyboard at the beginning of the current keyboard state change.

UIKeyboardFrameEndUserInfoKey – frame of the keyboard at the end of the current keyboard state change.

UIKeyboardAnimationDurationUserInfoKey – duration of the animation used to animate the change of the keyboard state.

UIKeyboardAnimationCurveUserInfoKey – animation curve used to animate the change of the keyboard’s state.

UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey are two most important and probably most commonly used elements of the userInfo dictionary. That being said, there is one important thing to remember. Coordinates ‘hidden’ behind these keys don’t take rotation factors applied to the window into account, so their values can seem be wrong. It is really important to remember to use convertRect:fromWindow or convertRect:fromView to make sure we work on proper keyboard coordinates.

The two following properties are most commonly used when we want to respond to a keyboard animation with our own animation. If we have the values for both the length of the animation’s duration and the curve used for the keyboard’s animation, we can use them to create our own animation, which will sync nicely with the keyboard’s own animation.

Responding to Notifications

Let’s imagine we have a view which is an UITableView object and its frame is equal to the screen bounds. In that particular case, the appearance of the keyboard will cause the bottom part of the UITableView content to be obscured by the keyboard frame. Moreover, the user won’t be able to scroll down to the bottom part of the content view which is put in table view. This is not the kind of experience we want to provide to our users.

We can handle this case in few different ways. The majority (if not all) of them require using keyboard notifications. We just listen for the appropriate notification and change some properties of our view hierarchy, so that user gets to see the entire content of the table view.

Earlier in this post, we added ourselves as the listeners for UIKeyboardWillShowNotification using the addObserver:selector:name:object method of the NSNotificationCenter class. Now, we can expand that code and add a method which will be called after the notification is received:

This code changes the frame of the table view so that it occupies only that part of the screen which is not hidden behind the keyboard frame. Furthermore, it changes the frame using an animation that perfectly matches the keyboard animation. The animation's duration and its curve are identical to the one used to show the keyboard, so the user shouldn't even notice any changes to the table view frame. Just don't forget to return the tableView frame to its initial state after the keyboard gets hidden!

Short Summary

After reading our introduction to the notification system, you should know how to listen for or respond to keyboard notifications, you’re well-versed in the keyboard's userInfo dictionary, and spelling the names of all of the keyboard notifications is not a problem anymore.

Well, you may think that you now know everything to properly work with a keyboard. In theory that might be true, but in practice your application can sometimes exhibit some unexpected behaviors. You still don't know the order in which notifications are sent and which of them can be absent in specific circumstances. Try to think for a moment about what will happen when there’s an external keyboard connected to the iPad? Not that obvious, isn’t it?

In the following parts of this post, I’d like to explore the notifications that occur when we change the state of the keyboard, e.g. docking the keyboard, showing the keyboard when there’s an external one connected to the device, etc. Additionally, I’ll try to take a close look at the values included in the userInfo dictionary. Finally, I’ll provide some code that will try to encapsulate some system notifications and broadcast my own. The latter notifications will have names equivalent to the system ones but will be sent in different circumstances.

Keyboard Magic

In iOS 5, Apple added a new feature to the system keyboard. Clicking and holding the keyboard button at the bottom right corner of the keyboard brings up a popup which allows you to merge/unmerge and dock/undock you keyboard. You can even move the undocked keyboard by holding and panning the abovementioned keyboard button along the screen.

Dragging keyboard triggers UIKeyboardWillChangeFrameNotification and UIKeyboardDidChangeFrameNotification notifications. First of them is send when user starts dragging and the second one after dragging is finished. Because of the fact system doesn't know what will be value of the UIKeyboardFrameEndUserInfoKey key at the beginning of the dragging, value set for this key is equal to CGRectZero in UIKeyboardWillChangeFrameNotification dictionary. Moreover, value of the UIKeyboardFrameBeginUserInfoKey key is equal to CGRectZero in UIKeyboardDidChangeFrameNotification.

You don't get UIKeyboardWillShowNotification and UIKeyboardDidShowNotificationnotifications when a non-standard keyboard is being shown. Hiding the keyboard doesn't trigger UIKeybardWillHideNotification and UIKeyboardDidHideNotification notifications. Still, UIKeyboardWillChangeFrameNotification and UIKeyboardDidChangeFrameNotification notifications work as expected and can be used to imitate other ones (to detect when a non-standard keyboard is being shown or hidden).

How to imitate UIKeyboardWillShowNotification and UIKeyboardDidShowNotification when showing unmerged/undocked keyboard?

Check whether UIKeyboardDidChangeFrameNotification was not preceded by UIKeyboardWillShowNotification.

Check whether the rectangle from userInfo's UIKeyboardFrameEndUserInfoKey is within screen bounds.

If both of these conditions are met, the keyboard will be shown in the unmerged/undocked state. Imitating UIKeyboardWillHideNotification and UIKeyboardDidHideNotification notifications obviously works in almost the same way, albeit with slightly different logic. You just need to switch “within” from condition no. 2 to “not within” and you’re set. Here is the code:

Toggling Dock and Merge State

Toggling the keyboard's dock and merge states causes the notifications to be sent in slightly different order than when the keyboard’s appearing or hiding:

If we dig deeper into userInfo properties of keyboard notifications, we’ll come upon even more weirdness than we expected. When unmerging or undocking the keyboard, the value for UIKeyboardFrameEndUserInfoKey in the userInfo dictionary is different in UIKeyboardDidHideNotification than in all the other notifications. The value of this key taken from UIKeyboardDidChangeFrameNotification suggests that the keyboard will be placed either in the screen or beyond it when other notifications suggest just the opposite. Also, UIKeyboardDidChangeFrameNotification is delivered with the UIKeyboardFrameBeginUserInfoKey key of the userInfo dictionary equal to CGRectZero.

Furthermore, docking or merging results in the sending of the UIKeyboardDidChangeFrameNotification notification with the value for the UIKeyboardFrameBeginUserInfoKey key equal to CGRectZero.

Splitting/Merging When Keyboard Is Undocked

Assuming the keyboard is in an undocked state, merging and splitting the keyboard makes the notification system send notifications in the following order:

That's right - UIKeyboardDidChangeFrameNotification is sent twice although there are no differences in keyboard frames passed in the userInfo dictionary. Also, do be careful with these frames - they sometimes represent pretty useless values. UIKeyboardFrameEndUserInfoKey is equal to CGRectZero in UIKeyboardDidChangeFrameNotification and UIKeyboardFrameBeginUserInfoKey is equal to CGRectZero in UIKeyboardWillChangeFrameNotification. Why two UIKeyboardDidChangeFrameNotification notifications? The only possible reason I found for that is captured on the screenshot underneath.

It seems that during the merging/splitting animation, there is change in the keyboard view/frame, and that’s probably the reason behind having two UIKeyboardDidChangeFrameNotification notifications. Just don't forget these notifications don’t always occur on a one-to-one basis!

Multiple Interface Orientations - Device Rotation

Device rotation is pretty weird when we look at it from the keyboard notification perspective. It can be really frustrating and hard to notice. Let's say your application supports multiple interface orientations and users start to rotate the device when they keyboard is displayed on the screen. What happens then? If we take a closer look at the keyboard animation which appears when we rotate the screen, we’ll quickly see that there’s nothing special to it.

But even a cursory glance at the notification logs shows us that something weird is happening. It looks like the rotation of the device makes the keyboard disappear and appear again. It’s almost imperceptible from the user’s perspective, but this notification behavior can have serious implications for the logic of the application. It looks like the easiest way to detect these notifications is to implement two templates methods of the UIViewController.

Assuming that they were implemented, this is the true order for notifications/method calls for device rotation:

willRotateToInterfaceOrientation:duration : - template method

UIKeyboardWillHideNotification

UIKeyboardDidHideNotification

UIKeyboardWillShowNotification

didRotateToInterfaceOrinetation:duration : - template method

UIKeyboardDidShowNotification

A simple flag set in willRotateToInterfaceOrientation:duration : (and unset in didRotateToInterfaceOrientation :) lets us ignore three out of the four notifications which appear during device rotation. The only one left is pretty easy to detect - if the keyboard is displayed and you get UIKeyboardDidShowNotification, don't do anything.

External Keyboard

Additional changes take place when we connect an external keyboard to the iPad. In this particular case, the notification behavior depends on the inputAccessoryView property of the control which was the reason for displaying the keyboard.

Let's say we have a UITextField or UITextView object and we set its inputViewAccessoryproperty. Assuming this object becomes a first responder, the view assigned to inputAccessoryView will be displayed above the keyboard on the screen. This enables programmers to provide a customized keyboard experience to the end users of the application.

If inputAccessoryView is not present or its height is equal to 0 points, no keyboard notifications are sent. My guess is that this is because in this case, no visual changes take place in application. Otherwise, all notifications behave as expected – which means they are being sent as in the majority of cases when the keyboard is displayed or hidden in a normal (not undocked or split) state.

What about the keyboard frame when inputAccessoryView is coupled with the currently displayed keyboard? Luckily for us, frames passed through keyboard notifications seem to take the displayed input view into account. That means keyboard frames passed in the objectInfo dictionary are unions of the keyboard's frame itself and the frame of the input view. Additionally, when there is an external keyboard hooked up to the device and only the accessory view is displayed, the keyboard's frame is the union of the two abovementioned frames (although the keyboard itself is not visible).

Keyboard Visibility

Due to the fact that there are so many states in which hiding or displaying the keyboard can take place, retaining a value that would inform us whether the keyboard is currently displayed on screen or not is not that obvious (and by displayed I mean visible to the user).

The easiest solution assumes the creation of a bool property which is later updated each time the system sends a UIKeyboardDidShowNotification or UIKeyboardDidHideNotification notification. Although really intuitive, this solution doesn't work properly when the keyboard is either undocked or unmerged.

A better approach to this problem is to update the bool property after we receive a UIKeyboardDidChangeFrameNotification notification. Just removeUIKeyboardFrameEndUserInfoKey from the notification's userInfo property and check whether it is contained within screen bounds.

Notice that we’re using the CGRectContainsRect function instead of CGRectIntersectsRect. This will ensure that the keyboardVisible property will be equal to YES only when the entire keyboard is visible, and by “entire keyboard” I mean keyboard + input accessory view. If you want this property to be equal to YES even when only the input accessory view is visible (when an external keyboard is connected to the device), use CGRectIntersectsRect instead.

Today there are lots of IT support companies. Which works on the same concept, which we work on, so we have to stand ourselves out and show our clients, what the actually need from us, that makes us different from others.

What all the Total IT solution companies do ? How does they work ? What are their strategy to cover the market and make money ? Here RulTech has a little story to make you understand, how we stand different from others.

RulTech's one of the director is in this Industry from more than 10-12+ years. He has worked with local as well as multinational companies. What his career experience was like, no one as a company cares for knowledge and efforts , what every company care for is economic growth. Here he was not referring to any company always, it was some time the company or the management or someone in the organization. But was this a real truth ? He had his thoughts over it and found that no it's not totally correct, the clients that this companies had really care and like knowledge more than money, they always loved the way people worked with their efficiency. They always gave more than expected to the people worked dedicatedly. Then he thought of bringing RulTech as an organization which will work totally differently then what normally companies does.

We work as team and not as seniors and juniors, we work with what we like the most and so we have expertise over it. We love doing over work and so we are never tired. We know what it feels when you need something and you don't get it, and so we have round the clock support. We work for money , buts it's not the most important reason, the most important factor for us is our work satisfaction and clients satisfaction, everything considered after this.

RulTech thinks that this is what you need from us, as we already have everything what other companies have but the points above makes us stand out. And we are proud of it.

Are you a student, working women, house wife, business, organization, industry , etc ?

Do you work with electronic gadgets, like computers, laptops, servers, smart phones, security systems, etc?

Have you got any issues, troubles, questions about installing, configuring, maintaining, or selecting the right product ? If you got any queries starting from making IT purchase which helps you with best use. Its time you need RulTech. We are one stop solution for everything.

Are you having any idea of innovative product and you confused with how / where to start with ? Again its time when you need RulTech.

Are you an IT admin, stuck at some issues and need some he from a product/service experts ? Its time for you when you need RulTech.

Are you starting your new company and need an infrastructure setup from scratch you are having trouble with different vendors for different things like for cabling you need different vendor, for installation you have different vendor, for setting up your applications you have different vendor, for servers you have different vendor, it defiantly feels like hell to deal with all at a time as they are interdependent on each other for the task. Its time you need RulTech leave all your IT needs on us. And relax and concentrate on your other core things. You just have to think on how to grow your core concept and we will help you with the best ideas in the Industry.

The real question is where is Information technology not used ? It's difficult to answer the above question because Information technology has become a part of our daily life , starting from reading online news to preparing presentations in office and communicating over email or Skype. Even while working or relaxing listening to our favourite song list synced over the cloud.

We are so used to it that we have forgotten the Pro's and Con's of the same. RulTech helps you to understand your need in an optimised, Smart, Secure and economical ways of using it.

Whenever you are in trouble RulTech stands besides you to keep you moving resolving all your issues, with its expert service and support. Choosing a technology or an IT product confusing, the team of experts helps you to select the best for your needs.

Are you are growing business or you are startup or you have setup wide business infrastructure our expert IT support advisors help you to grow fast. Also you can outsource your IT department so you can keep your clear focus on core business. We are one stop solution from consulting to development and maintenance.

So theoretically and practically when you think of IT , it's the time you need RulTech.

Information Technology is all around us, it's in our home, business, schools, every where. We are getting more and more dependent on Information Technology. There is BIG question to it WHY? We think because it makes our lives more easy and simple, Like when we are at home, we listen to on-line music, we shop on-line for our basic needs or we are at office we send mails or chat for instant communication which is more SECURE, AUTHENTIC and LEGAL way of communication. It means we are creating a on-line identity either for a person or a business or an organization, which is then judged by different people around.

I think that all sounds fun and simple, let us give you other view around of the technology, are you a techie or an IT experts or who knows only how to use these things. Here our point is when you start using this services or devices, you need to know more than what you use, like how to keep up this devices, how to keep up your accounts. There are many Do's and Dont's which Everyone is not aware off. Do you know what to do when your laptop get stuck and you have an important mail to send or you need to chat to your friend. Some business have their own servers for different purposes, do they know if they are using them at full potential? There are many questions which cannot be answered by a single person.

Here RulTech comes into the scenario, where RulTech has a team of experts for each technology and can help you all to either fix your laptop or consult you for the best use, of your existing infrastructure, we can also help you to keep up your existing infrastructure by teaching or implementing different policies for your business or your home.

RulTech is in the existence for 2.5+ years now and still growing, though it's a small amount of time as a company, our team consist of people who has more than 10+ years of experience in the industry, they really know what you want and what's the best for you, they give you round the clock support and services, in other words we would say, just handover your IT needs to us and you can concentrate more on your core business. Our Customer support and Services are the best in the Industry, We give Around the Clock Service, We Believe in High Quality. We are one stop solution for you, from consulting to development or maintenance.

We never say Customer is Right or Wrong, We help them to choose the Right. We always suggest the best and right thing which is suitable to the Customers.

What’s this all about?

This is just a short collection of some useful Xcode 4/5 plugins I use. Most of us Cocoa developers, I guess, are looking about for making our development environment a more friendly and “warm” place with features enriching the development experience.

This list is far off being complete and will be extended permanently. So if you like it you should take a look at it from time to time.

UncrustifyX

Xcode plugin to uncrustify the source code opened in the editor.The goals of this project are simple: Create a highly configurable, easily modifiable source code beautifier.

XCFixins

This project includes plugins (known as fixins) that extend Xcode and fix some of its annoying behaviors.

Xcode_beginning_of_line

XCode 4 plugin to make HOME key jump to the first non-whitespace line of code.

Dash Plugin for Xcode

This plugin allows you to use Dash (I think, this is a Must-Have!) instead of Xcode’s own documentation viewer when using option-click (or the equivalent keyboard shortcut) to view the documentation for the selected symbol.

Exterminator

A magic button in Xcode to exterminate the current project’s DerivedData directories.

KSImageNamed

Xcode plug-in that provides autocomplete for imageNamed: calls.

ColorSense

Plugin for Xcode to make working with colors more visual. Every time when place the cursor on a UIColor/NSColor code fragment it will show the current color of this code as an overlay. By clicking this color overlay you can edit the value just with the standard OS X color picker.

Mini Xcode

This is a plugin that makes it easier to run Xcode without the main toolbar. It adds keyboard shortcuts for selecting the active scheme and device, and a compact popup menu in the window title bar that shows the currently selected run configuration.

Lin

XVim

XVim is a Vim plugin for Xcode. The plugin intends to offer a compelling Vim experience without the need to give up any Xcode features.

Fuzzy Autocomplete for Xcode

A Xcode 5 plugin that adds more flexible autocompletion rather than just prefix-matching.Please read also this very interesting article of the developer of this plugin about the way of reverse engineering Xcode with dtrace.

XToDo

A plugin to collect and list the TODO, FIXME, ???, !!!

ClangFormat

An Xcode plug-in to to use clang-format from in Xcode. With clang-format you can use Clang to format your code to styles such as LLVM, Google, Chromium, Mozilla, WebKit, or your own configuration.

KFCocoaPodsPlugin

Alcatraz

Alcatraz is an open-source package manager for Xcode 5. It lets you discover and install plugins, templates and color schemes without the need for manually cloning or copying files. It installs itself as a part of Xcode and it feels like home.

SCXcodeMiniMap

SCXcodeMiniMap is a plugin that adds a source editor MiniMap to Xcode.

Conclusion

As we’ve illustrated above, some of the must have plugins and most popular. By sharing experiences we gained happiness, we hope to help improve apps built by our readers. There’s a lot more we’d like to share in future posts. If you have any thoughts or questions regarding plugins, don’t hesitate to contact us at This email address is being protected from spambots. You need JavaScript enabled to view it.

Want to Change Wallpaper ? Thank you Friends for Reporting the issues...Please help us to give you better app instead of you giving us Bad Review, Just try to give us 1 Chance to support you. Just Shaking your Phone will do the stuff, how Easy, Fast and Efficient Way is that!!! This app will just do the same. Install and Select the Folder for wallpaper and forget everything. Whenever you shake your phone it will change the wallpaper for you. Note: Long Click the Folder for Selecting. It has many other features like change wallpaper on unlocking the screen.

Notification like

Vibrate on wallpaper change.

Notification icon in title bar for easy access to the app.

Adjust the shake sensitivity as per your requirement.

Fully satisfied!!! Worth the cost. No need to worry about saving wallpaper on phone now....

Most Imp. Wallpaper Quality can also be controlled by the user. (HIGHER THE VALUE LOWER THE QUALITY, LOWER VALUE HIGER QUALITY) HIGH QUALITY might take some time to change wallpaper!!! No need to resize the images, so no space is utilized, the images are just processed for displaying as per the selected Quality and not stored anywhere. Your Images are not Changed in any conditions. You can preview the images using the preview button to have a view how your images would look as wallpaper. There is no option for Landscape mode for now. So if you are looking for something like that please do not install this app. We are surely going to add more functions like landscape mode, Face book Albums, Flicker Albums, Picasa Albums, Changing wallpaper on regular intervals, Randomly changing wallpaper, and many more, etc. But our main focus is on Stability and Performance, We would really not like to integrate any feature which would ,lower the performance or stability. Also no need to worry about rebooting your phone and turning the app On, As you can just select the option and the app will start automatically on reboot.

Project Details

Job Description

Welcome to Prep My Palate. The premiere dining directory that offers both visual and audio descriptions of restaurants entire menu. PMP wants to prepare you for your unique dining experience. Now, there is never a need to wonder about the presentation of your cuisine because it will always be visually at your finger-tips before you make your selection. Presenting you with a video, photo, and full descriptions of your actual meal, you can now select confidently knowing exactly what you are about to feast upon. So relax as you browse and enjoy the full experience of Prep My Palate!!!