How can I create a number pad with a decimal point separator character option in Xcode's Interface Builder Storyboard?
Changing Keyboard Type to Number Pad doesn't show a decimal option:
In iOS 4.1, there is a number pad with a decimal point available. You can select it programatically (in case you are supporting versions of iOS before 4.1) like so:
inputBoxTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
if (([[[UIDevice currentDevice] systemVersion] doubleValue] >= 4.1)) {
inputBoxTextField.keyboardType = UIKeyboardTypeDecimalPad;
}
You could choose any appropriate keyboard type (line 1). In this case, NumbersAndPunctuation includes a period in case the user's iOS version is before 4.1.
In Swift:
priceText.keyboardType = .decimalPad
In iOS 8 or above follow these steps:
Select the Textfield in Interface Builder
Edit Keyboard Type in xib or Storyboard
Select Decimal Pad
I have developed an open source custom decimal keyboard. Methods and implementations are very easy to use and you can change buttons or add/remove extra buttons as you see fit. Please have at look at the repository here TD-DecimalKeyboard and feel free to fork and contribute.
Related
I am having a bit of a problem with the UI/data entry part of my macOS application. In my application I have 6 NSTextFields, 1 NSDatePicker and 1 NSPopupButton. After typing in one NSTextField (specifically the one assigned to an outlet called "itemDescriptionField" in my code) It will not allow me to select other text fields or the date picker. The code can be found at:
https://github.com/Macintoshuser2/Inventory-Manager-macOS-Swift
How can I go about resolving this?
The description field has a number formatter. Type numbers or remove the number formatter.
I want to display an Emoji icon using it's decimal value, for example 
How can I display it in an UILabel ?
Thanks!
Try this
textLabel.text = #"\ue41e";
Instead of &#x, use \u. I hope this is the one you want.
I place some textfields in my app,those textfield allows only numbers 0,1..9 and .symbol.
For that my code is
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
static NSCharacterSet *charSet = nil;
if(!charSet) {
charSet = [[[NSCharacterSet characterSetWithCharactersInString:#"0123456789."] invertedSet] retain];
}
NSRange location = [string rangeOfCharacterFromSet:charSet];
return (location.location == NSNotFound);
}
It works fine,
But when ever i press ABC & #+= buttons keypad changes to another type.
I need to prevent that,user can use numbers and .,X keys only.
Rest of them not active ,if they are visible that not the problem
How can i done this.
can any one ple help me.
Thank u in advance.
There is a keyboard designed for this: UIKeyboardTypeDecimalPad
If you can target your app for iOS 4.1 and later, use #jtbandes suggestion.
The main advantage of using built-in keyboard types in iPhone SDK is they support internationalization. If you don't need letters, just numbers, I would suggest just building a custom keyboard from UIButtons with just the keys you want. Keep the keyboard from displaying (resignFirstResponder on textFieldShouldBeginEditing). You can include playing "Tock.aiff" from the "com.apple.UIKit" bundle to make it seem authentic.
If you need to support OS versions prior to 4.1, you can do what App Cubby did in some of their apps (like Gas Cubby) - they used the number pad keyboard (UIKeyboardTypeNumberPad) and overlaid a UIButton containing the dot in the bottom left corner. The keyboard handles the 0-9 input and the action for dot button is configured to append a '.' to the current string value.
How can I get the numeric keyboard with the decimal separator? Currently I am stuck with UIKeyboardNumberPad.
you can try this
UIKeyboardTypeDecimalPad
typedef enum {
UIKeyboardTypeDefault,
UIKeyboardTypeASCIICapable,
UIKeyboardTypeNumbersAndPunctuation,
UIKeyboardTypeURL,
UIKeyboardTypeNumberPad,
UIKeyboardTypePhonePad,
UIKeyboardTypeNamePhonePad,
UIKeyboardTypeEmailAddress,
UIKeyboardTypeDecimalPad,
UIKeyboardTypeTwitter,
UIKeyboardTypeWebSearch,
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable // Deprecated
} UIKeyboardType;
If you don't like those, you can always modify them in code...
http://openradar.appspot.com/6635276
This has a solution:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/6573-howto-customize-uikeyboard.html
The UIKeyboardTypeNumbersAndPunctuation is probably the least-bad option, unless you have the time and resources to roll your own keyboard.
The iPhone SDK currently does not offer a keypad (0-9) + decimal button UIKeyboard. I suspect this was designed because for the majority of use cases, it is not needed.
See this previous StackOverflow question discussing the (lack of) need for a decimal separator for currency inputs. I also wrote a blog post about this very topic.
However, if you really do need a keypad + decimal button keyboard, your only option will be to roll your own custom keyboard. Contrary sbwoodside's answer, you really want to shy away from customizing the existing UIKeyboard. While this may be easy to do, it relies upon private classes that can change anytime...meaning your hack could break in the future without warning.
In Apple's iPhone apps (like Contacts), they have a nice magnifying glass icon at the top of the table view index. Since the table view index API is character-based, I assume that this magnifying glass is a Unicode character. So far I've resorted to placing a question mark character there, but that looks lame.
Can anyone tell me what character the magnifying glass is?
Returning UITableViewIndexSearch as section index title (same as #"{search}") also works.
In Swift you would use UITableView.indexSearch.
#"{search}" FTW.
Return that title and it's magically replaced by the correct glyph.
In tableView:sectionForSectionIndexTitle:AtIndex: explicitly scroll to the top and return NSNotFound:
- (NSInteger) tableView:(UITableView *)tableView
sectionForSectionIndexTitle:(NSString *)title
atIndex:(NSInteger)index {
if (index == 0) {
[tableView setContentOffset:CGPointZero animated:NO];
return NSNotFound;
}
return index;
}
There already is an existing UTF codepoint for the magnifying glass. It is U+1F50D. However it's slightly tricky getting Xcode to recognize this number. According to Apple's String Programming Guide the UTF bits should be split into two UTF-16 surrogate pairs (0xD83D, 0xDD0D). Check with this surrogate pair calculator for reference.
An NSString instance with the contents of the surrogate pair can be obtained with:
[NSString stringWithFormat:#"%C%C", 0xD83D, 0xDD0D];
A constant UITableViewIndexSearch is used in the case, as noted here:
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/doc/constant_group/Section_Index_Icons
You can certainly put a Unicode character in the table view index (I've done this with other characters) and put your header in the first table section in lieu of of the tableViewHeader. That said, I've yet to find the magnifying glass in any of the unicode references. The closes I've found is the Telephone Recorder symbol - ⌕ (\u2315). Unfortunately, it points in the wrong direction and the "handle" extends into the "magnifying glass."
In the sectionIndexTitlesForTableView add a NSMutableArray* titles for example and in addition to your indexes add the [titles addObject: UITableViewIndexSearch]
I know this is an old post but since it's similarly related to what I was looking for... If anyone is looking for the Unicode Character of the magnifying glass, it would be this one \u128269 represented by this: 🔍 that is if your browser is displaying unicode
You can view the full detail of it on this web site:
http://www.charbase.com/1f50d-unicode-left-pointing-magnifying-glass
In my case I wanted to do a search input box with the magnifying glass in it, I manage to do it via this piece of code, please note that we need to use a special font that might not work in older browser or OS:
<input type="text" style="font-family: Segoe UI Symbol;" placeholder="🔍">
This works on my machine Win7 in both Firefox and Chrome but IE is always an exception with placeholder in this case.
Someone claims that Apple told them this isn't supported in the SDK.
I can understand why someone might not want to use the image, although it is very pretty... characters are so much easier to maintain and can scale with little effort.
⚦ is another unicode option for a magnifying lens-like glyph.. again it's not facing the correct direction.. I believe it's really some kind of hermaphroditic gender symbol. The html for the unicode symbol above is ⚦
I really think a magnifying lens symbol should be added to the unicode character set under "26: Misc. Symbols".
You could use a space as the character for the index and then overlay an UIImageView that has user interaction disabled and contains the following image:
(source: booleanmagic.com)