The code needs to be changed to below: This code works in 3.2 and 4.0.
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES || [[keyboard description] hasPrefix:@"<UIPeripheralHostView"] == YES) {
}
That was all I had to change. I hope this helps you!
Well I'm back to same issue again. The decimal works on the iPad 3.2 but not on the latest beta for iPhone 4.0. Anyone have an idea how to fix this?
It is still not working in Beta4
I know Apple would prefer developers to use the new public API UITextView inputView property (as of OS3.2) but is it possible to write code that is backward compatible? e.g. use the hasPrefix:@"<UIKeyboard" method if the OS is older than 3.2 or use inputView property for 3.2 and over.
Is seems a bit of a chicken and egg situation. Compile as 4.0 and it won't run on a older OS. Compile for older OS and the inputView property doesn't exist to be able to be called.
I have the exactly the same problem. I'm not that great of a coder so I'd rather not create and maintain my own individual solution for the numeric keypad with a decimal because I will probably screw it up in some way. Who knows what will or will not work with the new hardware comes out with different screen resolutions next month? However, I've got a few apps that are going to need to be updated before OS4 is released to the general public so that probably means it will need to be addressed by the beginning of WWDC.
If you found a solution to the problem of adding a decimal button to the numeric keypad under OS4, would you post some info on it? Thanks.
I'm afraid I don't know the answer to that one. In my case I have a whole keyboard already defined. I was using the <UIKeyboard trick to ensure my keyboard was on top of the Apple one. In OS4 my keyboard just disappeared so now I have the code in place that says
if OS >= 3.2 then
use UITextView inputView
else
use the <UIKeyboard trick
Screen shots of the project can be seen at HotTyper.com if you want to see what I am doing to the keyboard.