Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tutorials

Reply
 
LinkBack Thread Tools Display Modes
Old 01-03-2010, 01:13 PM   #26 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 201
Default

Quote:
Originally Posted by thewitt View Post
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.
not_too_shabby is offline   Reply With Quote
Old 01-03-2010, 01:26 PM   #27 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 169
Default

Nothing official.

My App with the "." key added was not rejected, however the next update will have my own fully custom keyboard as a replacement.

-t
thewitt is offline   Reply With Quote
Old 01-22-2010, 08:19 AM   #28 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 12
Default

Quote:
Originally Posted by mkenney View Post
Can you post a link to the discussion on the Apple forum? Have they offered any suggestions to an approved solution?
I think it is this one: https://devforums.apple.com/thread/22301
D7BUSTxUYtx1HZ is offline   Reply With Quote
Old 02-11-2010, 11:21 AM   #29 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 9
Default Playing system sound

Quote:
Originally Posted by slahteine View Post

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 would like to play original keyboard sound

thanks
nacho4d is offline   Reply With Quote
Old 02-24-2010, 10:48 AM   #30 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 1
Default

Quote:
Originally Posted by slahteine View Post
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
teddfox is offline   Reply With Quote
Old 02-24-2010, 01:50 PM   #31 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 9
Default

Quote:
Originally Posted by teddfox View Post
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?

Regards Ignacio
nacho4d is offline   Reply With Quote
Old 02-26-2010, 09:11 PM   #32 (permalink)
Programming Wizard
 
slahteine's Avatar
 
Join Date: Oct 2008
Location: Northampton, MA USA
Age: 45
Posts: 193
Send a message via AIM to slahteine Send a message via Yahoo to slahteine Send a message via Skype™ to slahteine
Default

Quote:
Originally Posted by teddfox View Post
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.
|

slahteine is offline   Reply With Quote
Old 03-18-2010, 08:24 PM   #33 (permalink)
Pof
Registered Member
 
Join Date: Jan 2010
Posts: 1
Default

Quote:
Originally Posted by keyboardcowboy View Post
****** IMPORTANT*******
[...]
How can I download attachements from your post ?
Pof is offline   Reply With Quote
Old 04-01-2010, 01:19 PM   #34 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 1
Default

@@ Thanks
fans is offline   Reply With Quote
Old 04-08-2010, 12:48 AM   #35 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 72
Default

Quote:
Originally Posted by nacho4d View Post
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.
F.R.E.E. is offline   Reply With Quote
Old 04-08-2010, 09:03 AM   #36 (permalink)
Physician developer
 
StatCoder's Avatar
 
Join Date: Aug 2008
Location: Austin, TX
Posts: 221
Default

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:

www.CocoaLines.com - Blog

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.
StatCoder is offline   Reply With Quote
Old 04-09-2010, 08:11 PM   #37 (permalink)
Registered Member
 
Join Date: May 2009
Posts: 72
Default

Quote:
Originally Posted by StatCoder View Post
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:

www.CocoaLines.com - Blog

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.
F.R.E.E. is offline   Reply With Quote
Old 04-16-2010, 06:23 PM   #38 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 1
Default

Hi everybody,

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 View Post
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]);
		}
	}
}
Do you think this would be rejected ?


Thanks .
0x5A is offline   Reply With Quote
Old 04-22-2010, 06:04 PM   #39 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 17
Default

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.
tom.talty is offline   Reply With Quote
Old 05-09-2010, 03:44 PM   #40 (permalink)
Physician developer
 
StatCoder's Avatar
 
Join Date: Aug 2008
Location: Austin, TX
Posts: 221
Default

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?
StatCoder is offline   Reply With Quote
Old 05-09-2010, 03:58 PM   #41 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 9
Smile inputView and accessoryInputView

Quote:
Originally Posted by StatCoder View Post
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

Code:
UITextView * textView = [[UITextView alloc] initWithFrame:frame];
MyKeyboard *mykeyboard = [[MyKeyboard alloc] initWithSomething:something];
textView.inputView = myKeyboard;
[myKeyboard release];

[viewController.view addSubview:textView];
[textView release];
[textView becomeFirstResponder]
;

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.

I hope it helps

Last edited by nacho4d; 05-09-2010 at 04:09 PM.
nacho4d is offline   Reply With Quote
Old 05-13-2010, 06:19 PM   #42 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Atlanta
Posts: 411
Default

The post above mine is a spammer. Click report
funkytaco is offline   Reply With Quote
Old 05-22-2010, 04:40 PM   #43 (permalink)
Physician developer
 
StatCoder's Avatar
 
Join Date: Aug 2008
Location: Austin, TX
Posts: 221
Default

Quote:

--> 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.

Last edited by StatCoder; 05-22-2010 at 04:53 PM.
StatCoder is offline   Reply With Quote
Old 05-27-2010, 11:35 AM   #44 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: Espoo, Finland
Posts: 16
Default The dot is not always a dot

Many countries use a comma as a decimal separator.

There is a Wikipedia article about this: Decimal separator - Wikipedia

You can find out in code, what the decimal separator currently is:

NSLocale *currentUsersLocale;
currentUsersLocale = [NSLocale currentLocale];
NSString *decimalSeparator = [currentUsersLocale objectForKey:NSLocaleDecimalSeparator];

Then you would also need two more graphics:

commaHighlighted.png
commaNormal.png
idevbooks is offline   Reply With Quote
Old 06-05-2010, 06:42 AM   #45 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 159
Default

Hi,

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?

Thanks Aaron
__________________
Aaron
bluemonkey is offline   Reply With Quote
Old 06-07-2010, 01:13 AM   #46 (permalink)
Physician developer
 
StatCoder's Avatar
 
Join Date: Aug 2008
Location: Austin, TX
Posts: 221
Default

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.

iPhone: Number Pad with a decimal point (OS 3.0, OS 4.0) using public API devedup.com
StatCoder is offline   Reply With Quote
Old 06-07-2010, 01:47 AM   #47 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 159
Default

Thanks for the link to the Blog StatCoder, it looks like the blog writer removed the private API's so this should be compatible with OS4.

Thanks Aaron
__________________
Aaron
bluemonkey is offline   Reply With Quote
Old 06-07-2010, 04:31 AM   #48 (permalink)
Registered Member
 
Jules2010's Avatar
 
Join Date: Apr 2010
Location: UK
Posts: 157
Default

Quote:
Originally Posted by StatCoder View Post
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.

iPhone: Number Pad with a decimal point (OS 3.0, OS 4.0) using public API devedup.com
What about the Done button.
I've had a look at your sample code and I think done images would be need.
Hows about an article on that?
Jules2010 is offline   Reply With Quote
Old 07-02-2010, 11:58 AM   #49 (permalink)
Registered Member
 
Join Date: Jan 2010
Location: NYC
Posts: 37
Default

Quote:
Originally Posted by Jules2010 View Post
What about the Done button.
I've had a look at your sample code and I think done images would be need.
Hows about an article on that?

Jules2010,
here is a way to add a done button as a tool bar:

http://www.iphonedevsdk.com/forum/ip...-keyboard.html

the problem is it does not work so well in 4.0. I will let you know if I come up with a solution.
beleg_1998 is offline   Reply With Quote
Old 07-02-2010, 12:12 PM   #50 (permalink)
Registered Member
 
Jules2010's Avatar
 
Join Date: Apr 2010
Location: UK
Posts: 157
Default

No worries, I got it sorted.
Jules2010 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 253
24 members and 229 guests
ADY, AragornSG, bookesp, chillyh, dacapo, Dani77, Davey555, Desert Diva, Dominus, dre, glenn_sayers, HemiMG, JasonR, LEARN2MAKE, M.A.S., marshusensei, mer10, nobre84, Oral B, prchn4christ, Raggou, Rudy, spiderguy84, themathminister
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:28 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0