• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to set keyboard type for custom view?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to set keyboard type for custom view?


  • Subject: Re: How to set keyboard type for custom view?
  • From: Conrad Shultz <email@hidden>
  • Date: Tue, 31 May 2011 12:49:11 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 5/31/11 12:23 PM, Jeffrey Walton wrote:
> Hi All,
>
> I have a view that accepts input using UIKeyInput. The VC's
> viewWillAppear: calls [myHiddenView becomeFirstResponder] which shows
> the alphanumeric keyboard. I get input as expected through insertText:
> and deleteBackwards:.
>
> How does one change the keyboard type to UIKeyboardTypeNumberPad? I've
> tried conforming to UITextInputTraits in my custom view, but the
> keyboard does not appear to reach back to my view for the trait. Is
> there anything special when a protocol only includes properties? Or
> perhaps I have missed another [important] detail?

Can you show code?  I ask because I just implemented a minimal example
that I believe does what you are asking, with nothing fancy.  I did not
implement the backing store for UIKeyInput, but I don't see that that
should matter here.

In a UIView subclass (declared with <UITextInputTraits, UIKeyInput>) I
implemented:



- - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
	[self becomeFirstResponder];
}

- - (BOOL)canBecomeFirstResponder
{
	return YES;
}

#pragma mark UIKeyInput methods
- - (void)deleteBackward
{
}

- - (void)insertText:(NSString *)text
{
}

- - (BOOL)hasText
{
	return NO;
}

#pragma mark UITextInputTraits methods
- - (UIKeyboardType) keyboardType
{
	return UIKeyboardTypeNumberPad;
}



And, as expected, when I tapped the UIView (in simulator), the numeric
keypad appeared.

This sounds like what you did, though...?  The only thing I could think
of is that your view controller is interfering, but the view comes
before its controller in the responder chain, so it's not clear how this
would happen (barring some very unorthodox implementation).

- --
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFN5UY3aOlrz5+0JdURAjCKAJ4okqU/1NYWelDbWvXJ+/Qk5cFR+gCfZmzt
A2LxTk3sa3kuVVVXpYa1k8Y=
=ONTG
-----END PGP SIGNATURE-----
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to set keyboard type for custom view?
      • From: Jeffrey Walton <email@hidden>
References: 
 >How to set keyboard type for custom view? (From: Jeffrey Walton <email@hidden>)

  • Prev by Date: How to set keyboard type for custom view?
  • Next by Date: Re: How to set keyboard type for custom view?
  • Previous by thread: How to set keyboard type for custom view?
  • Next by thread: Re: How to set keyboard type for custom view?
  • Index(es):
    • Date
    • Thread