I could not find it in a quick search and I'm off to a meeting now.
Apparently we were warned not to do this in the SDK 3.0 release notes, and since this "trick" relies on an undocumented call to find the name of the keyboard (walking the subviews until we find the one with the name we think it should be) it's going to - if it doesn't already - flag the code checker somehow...
The Apple recommendation was to submit a bug report.
The only other recommendation - from non-Apple employees in the forum - was to create a completely new, custom keypad and handle all the necessary events yourself. Not a great solution.
My App was just submitted with the Decimal point added to the keypad using this trick - so I guess I'll see if it gets through the gauntlet or not.
I've begun work on a totally custom keypad as a backup plan, but it's going to take some time to get it right and fully functional I'm afraid.
-t
Any update on this? I would like to implement a custom keyboard similar to what TipTap had done. Basically it's just a number pad with a clear, decimal point and a Done button which would work perfect for my Apps. It would be nice if within IB you could arrange for yourself a custom keyboard without having to roll everything from scratch.
Here are two handy methods that helped to get the proper behavior:
Code:
// Play the built-in keyboard click sound
- (void)playKeyboardClick {
AudioServicesPlaySystemSound(0x450);
}
Is this working currently in 3.1 or above?
I knew the copy and paste stuff to handle the cursor in UITextField, but I found very interesting the sound trick!.
But is not working!!
How did you found 0x450?
I gave up trying to customize the keyboard itself, but I'd still consider hiding the keyboard and using my own total replacement.
For the next version of my app I took a cue from FastWriter (Fast Writer Adds Extra Row of Keys to the iPhone’s Keyboard Art of the iPhone) and added an extra row of keys. I even went to the trouble of Photoshopping up the enlarged key thingies so I could make it look and act just like the regular keyboard.
Here are two handy methods that helped to get the proper behavior:
Code:
// Play the built-in keyboard click sound
- (void)playKeyboardClick {
AudioServicesPlaySystemSound(0x450);
}
// Insert a string into a UITextField at the cursor position
- (void)insertString:(NSString *)text intoTextField(UITextField *)textfield {
UIPasteboard* generalPasteboard = [UIPasteboard generalPasteboard];
NSArray* items = [generalPasteboard.items copy];
generalPasteboard.string = text;
[textfield paste:self];
generalPasteboard.items = items;
[items release];
}
My concern is when the keyboard dismisses, does it dismiss with the default keyboard, or does it dismiss on it's own. I have a custom toolbar on top of the default keyboard, but when the keyboard is dismissed, the toolbar dismisses separately and looks like cluttered rubbish
My concern is when the keyboard dismisses, does it dismiss with the default keyboard, or does it dismiss on it's own. I have a custom toolbar on top of the default keyboard, but when the keyboard is dismissed, the toolbar dismisses separately and looks like cluttered rubbish
Ok...
My app is using this "trick" and personally I don't think there is someone who has been warned by Apple for using this "trick"
Actually we are not using any private API (not directly) .
I mean, we don't have any private API object reference in our code.
(We have an casted UIKeyboard into UIView, and UIView is public so, we are good right?)
I have received some messages from apple warning me for using other APIs (in other apps) but my app was never rejected.
So. I think the easiest way is to do this trick.
When you use this "trick" you don't have to worry about keyboard animations your keyboard will show and hide the same way as apple's keyboard does. (since your keyboard is attached to apples's keyboard, like a super layer)
If you have a custom toolbar, you probably want to make it dissapear or appear (with an animation or not) when you get a keyboardWillHide or keyboardWillAppear notification.
With 3.0 OS you can get the animation curve the keyboard and you can use it to implement your own animation that should look like the original iPhone keyboard. Or maybe just a fade effect is enough.
I have to say that In first place I actually implemented my own keyboard but is really such a pain!! because:
You have to handle appear and dissappear animations.
And the most difficult part you have to find a way to show a cursor!, finding the cursor position is not easy!
Not showing the original keyboard implies that text will never become first responder. So you will never get Notifications when the keyboard is about to come out and etc. And you won't get a cursor. So you really are at your own.
But... (And this is a BIG BUT)
We all should start looking at new APIs
I cannot say further since 3.2 is still beta and I think there is a NDA.
But maybe we should start looking at new UITextField and UITextView and UITextTraits UITextInput ... etc
3.2 API diffs is a good place to start.
I would like to start a new thread but I am afraid we cannot yet. can we?
My concern is when the keyboard dismisses, does it dismiss with the default keyboard, or does it dismiss on its own. I have a custom toolbar on top of the default keyboard, but when the keyboard is dismissed, the toolbar dismisses separately and looks like cluttered rubbish
In my implementation I have the extra row of keys slide up and down in almost perfect sync with the keyboard, and it looks great. The extra-keys view isn't a child view of the system keyboard. Rather, it's a subview of the main window view, layered behind the keyboard. To get the sliding animation to sync up well, I used an animation duration of 0.3 seconds.
To see it in action grab my free app "ChordCalc Lite" and tap on the chord name at the top of the screen.
__________________
|
| I wrote ChordCalc ... A cool fretboard calculator.
|
Ok...
My app is using this "trick" and personally I don't think there is someone who has been warned by Apple for using this "trick"
Actually we are not using any private API (not directly) .
I mean, we don't have any private API object reference in our code.
(We have an casted UIKeyboard into UIView, and UIView is public so, we are good right?)
I have received some messages from apple warning me for using other APIs (in other apps) but my app was never rejected.
So. I think the easiest way is to do this trick.
When you use this "trick" you don't have to worry about keyboard animations your keyboard will show and hide the same way as apple's keyboard does. (since your keyboard is attached to apples's keyboard, like a super layer)
If you have a custom toolbar, you probably want to make it dissapear or appear (with an animation or not) when you get a keyboardWillHide or keyboardWillAppear notification.
With 3.0 OS you can get the animation curve the keyboard and you can use it to implement your own animation that should look like the original iPhone keyboard. Or maybe just a fade effect is enough.
I have to say that In first place I actually implemented my own keyboard but is really such a pain!! because:
You have to handle appear and dissappear animations.
And the most difficult part you have to find a way to show a cursor!, finding the cursor position is not easy!
Not showing the original keyboard implies that text will never become first responder. So you will never get Notifications when the keyboard is about to come out and etc. And you won't get a cursor. So you really are at your own.
But... (And this is a BIG BUT)
We all should start looking at new APIs
I cannot say further since 3.2 is still beta and I think there is a NDA.
But maybe we should start looking at new UITextField and UITextView and UITextTraits UITextInput ... etc
3.2 API diffs is a good place to start.
I would like to start a new thread but I am afraid we cannot yet. can we?
Regards Ignacio
So I have been playing around with the 3.2 SDK some, and guess what, the View hierarchy has changed and this technique no longer works.
I also have apps released with a decimal point in the number pad. Works quite well despite some usability issues I noticed in testing.
When I got my iPad, I found that this technique wasn't working. The decimal doesn't appear on the numeric keypad nor does it register. I found a fix at:
It does work and my iPad apps with the keypad have been updated.
Also, be aware that Apple is flagging apps that use "keyboardDidShow:" as an undocumented API. They won't reject your app but they will send you a warning email to remove it for the next submission.
When I got my iPad, I found that this technique wasn't working. The decimal doesn't appear on the numeric keypad nor does it register. I found a fix at:
It does work and my iPad apps with the keypad have been updated.
Also, be aware that Apple is flagging apps that use "keyboardDidShow:" as an undocumented API. They won't reject your app but they will send you a warning email to remove it for the next submission.
interesting, I tried that as well, but it didn't work for me. I will have to recheck my work and see what I did wrong.
I found out there is something new in the iPhone SDK 3.2 which is (UITextField class) :
inputView: The custom input view to display when the text field becomes the first responder. If the value in this property is nil, the text field displays the standard system keyboard when it becomes first responder. Assigning a custom view to this property causes that view to be presented instead. The default value of this property is nil.
inputAccessoryView: The custom accessory view to display when the text field becomes the first responder. The default value of this property is nil. Assigning a view to this property causes that view to be displayed above the standard system keyboard (or above the custom input view if one is provided) when the text field becomes the first responder. For example, you could use this property to attach a custom toolbar to the keyboard.
This would allow us to implement our own keyboard but still having the cursor, cut-copy-past, etc... Unfortunately, iPhone OS 3.2 is iPad only ...
Quote:
Originally Posted by StatCoder
Also, be aware that Apple is flagging apps that use "keyboardDidShow:" as an undocumented API.
I dont' see how "keyboardDidShow:" can be an undocumented API, it's just a method that could be given another name =/. It just answers to the UIKeyboardWillShowNotification notification which is public.
If Apple's warning is about the use of UIKeyboard then I think we can completely hide the window containing the keyboard so we don't make any calls to a UIKeyboard object :
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
// ...
}
- (void)keyboardWillShow:(NSNotification *)note
{
// To hide the keyboard you can hide the window
// that contains the keyboard (description starts
// by "<UITextEffectsWindow") or hide the keyboard
// itself (description starts by "<UIKeyboard" or
// "<UIPeripheralHostView" on the iPad").
NSArray* windows = [[UIApplication sharedApplication] windows];
NSUInteger windowCount = [windows count];
// Going through each window of our application
for (NSUInteger i = 0; i < windowCount; i++)
{
/* Hidding the window containing the keyboard */
UIWindow* currentWindow = [windows objectAtIndex:i];
if ([[currentWindow description] hasPrefix:@"<UITextEffectsWindow"])
{
[currentWindow setHidden:YES];
}
/* Print some information (windows & their subviews) ... */
NSArray* currentWindowSubviews = [currentWindow subviews];
NSUInteger subViewCount = [currentWindowSubviews count];
NSLog(@"Window #%u : %@", i, currentWindow);
for (NSUInteger j = 0; j < subViewCount; j++)
{
NSLog(@" View #%u : %@", j, [currentWindowSubviews objectAtIndex:j]);
}
}
}
Can we do this in the new 4.0 SDK? I heard a lot of people saying that a custom keyboard might not be allowed in the new sdk since apple is cracking down and this uses a "unique modification" and that sub viewing the UIKeyboard is not allowed. I basically just need a UIKeyboard using the numberpad with a decimal and done button.
It looks like this method will not work on iPhone OS4 devices. The keyboard is not modified. I guess that means we have probably have about four weeks to modify our apps or they will not work when iPhone OS4 is released to the public. Anyone have any ideas?
It looks like this method will not work on iPhone OS4 devices. The keyboard is not modified. I guess that means we have probably have about four weeks to modify our apps or they will not work when iPhone OS4 is released to the public. Anyone have any ideas?
Super easy. in iPhone OS 4.0 as same as iPhone 3.2 there is a inputView and accessoryInputView property
@property (readwrite, retain) UIView *inputView
so you can use it like this: (from my head, not tested)
for example override viewDidLoad in your ViewController
And then you will have your keyboard without all the searching for UIKeyboard view everytime the keyboard will appear. No notifications, nothing. Easy.
If you want to implement more difficult stuff you probably want to look at documentation and look for iPad Programming guide, UITextInput and other new protocols are explained so you can implement your textView and get capabilities like text correction, conversion (in case of japanese, etc.) from the OS.
Cheers.
--> If you want only a dot Button on numeral keyboard, have you tried adding you button to your application.window object?
In theory if you add a view there it should appear above the keyboard. You will have to handle animations to make it look native.
--> If you want only a dot Button on numeral keyboard, have you tried adding you button to your application.window object?
In theory if you add a view there it should appear above the keyboard. You will have to handle animations to make it look native.
I hope it helps
Thanks for your help. I have tried
Code:
// Make the dot a subview of the view containing the keyboard.
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubview:self.dot];
// Bring the dot to the front of the keyboard.
[[[[UIApplication sharedApplication] windows] objectAtIndex:0] bringSubviewToFront:self.dot];
However, this still puts the decimal button behind the numeric keypad, probably because the keypad is added after this is called. I guess one still has to access the numeric keypad view either to add button on top of it or to modify it and set it as the inputAccessoryView. I guess that was the whole point of using the original routine to iterate through the views to identify for the keyboard view.
I have been using the custom number pad in my application for a number of months now to add the decimal place to the keyboard. However last night I received an email from Apple and I think they are not allowing this type of code / private API's now
"The organization and layout of the view hierarchy for the keyboard are undocumented and private. There are no public APIs in the iPhone OS SDK provided for keyboard customizations on the iPhone, and modifying or extending the view hierarchy of the keyboard is modifying or extending a private API."
Has anyone else had any similar emails from Apple, or rejections based on the customised keypad?
This blog seems to have posted a working solution. It overlays a decimal button on the window by giving the numeric keyboard time to become the topmost screen. In my testing, it seems to work fine.
This blog seems to have posted a working solution. It overlays a decimal button on the window by giving the numeric keyboard time to become the topmost screen. In my testing, it seems to work fine.