UIButton over keyboard

Discussion in 'iOS Programming' started by nomar383, Jul 30, 2009.

  1. nomar383 macrumors 65816

    nomar383

    Joined:
    Jan 29, 2008
    Location:
    Rexburg, ID
    #1
    Okay, so I have a NumPad keyboard that pulls up, but I need a period key. My idea was to create a UIButton over the top of the empty space on the bottom left of the NumPad. However, the button is always underneath the keyboard when it's pulled up. Any ideas?
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Put it in your view that appears above the keyboard next to the text field.
     
  3. nomar383 thread starter macrumors 65816

    nomar383

    Joined:
    Jan 29, 2008
    Location:
    Rexburg, ID
    #3
    Can you clarify this a bit?
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    You have a textfield in a view. Put the button in that same view next to it. When the user touches the textfield the keyboard appears. The keyboard only covers half the screen. You can still see the textfield and some space around it. Have the action of this button insert the dot into the textfield.

    I have a UI where I show the URL keyboard. I have a couple buttons below the textfield that enter tilde and a file extension that is common for users of my app.

    I guess I'm not sure what the number pad keyboard looks like. Does it cover the whole screen or just half like the URL keyboard?
     
  5. nomar383 thread starter macrumors 65816

    nomar383

    Joined:
    Jan 29, 2008
    Location:
    Rexburg, ID
    #5
    The Numpad takes up the same space as every other keyboard, but only has 10 numbers and a backspace key.

    I found a perfect solution for this, complete with pngs for the period from this blog:
    http://billabonger.net/blog/2009/01/add-a-decimal-to-uitextfield-number-pad-keyboard/

    It works great and the period looks very natural. It's a little crazy that this took nearly 50 lines of extra code. It should really be an option in IB for the Numpad keyboard.
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    Adding a subview to a view that you don't own is brittle. There are lots of things that can change that will prevent your code from working, not to mention crashing.

    Up to you.
     
  7. nomar383 thread starter macrumors 65816

    nomar383

    Joined:
    Jan 29, 2008
    Location:
    Rexburg, ID
    #7
    Yeah, it's a lot of lines of code that code break at some point, in fact I was surprised that is works flawlessly in 3.0.

    I've decided to go with it and hopefully Apple will just add this option at some point and I can remove these extra steps.

    If my program were more complex than a 3 input boxes and 1 view, I would have definitely gone your route
     
  8. nomar383 thread starter macrumors 65816

    nomar383

    Joined:
    Jan 29, 2008
    Location:
    Rexburg, ID
    #8
    I submitted this as a feature request to Apple. I have already had to clean up the code a little to prevent multiple periods from being input.
     

Share This Page