uitextinput

Getting the currently active keyboard language as NSLocale

吃可爱长大的小学妹 提交于 2021-02-17 06:10:19
问题 I already found a lot of approaches for this but no working solution. Here's what I tried and didn't work. (1) Simply calling primaryLanguage() UITextInputMode().primaryLanguage → always returns nil :-/ (2) Subscribing to UITextInputCurrentInputModeDidChangeNotification notifications override func viewDidLoad() { NSNotificationCenter.defaultCenter().addObserver(self, selector: "changeInputMode:", name: UITextInputCurrentInputModeDidChangeNotification, object: nil) } func changeInputMode

UITextInputMode.activeInputModes() crashes in Swift 2

耗尽温柔 提交于 2020-01-30 05:25:21
问题 I want to get UITextInputMode in Swift 2 but UITextInputMode.activeInputModes() crashes. let x = UITextInputMode.activeInputModes() // crash here for t in x { print(t) } 回答1: It is a bug in Xcode 7 as mentioned HERE. Which says: Summary: Prior to the Xcode 7 GM, UITextInputMode.activeInputModes() returned an array of UITextInputMode instances. However, in the Xcode 7 GM, the method signature in the header file and documentation states that it returns an array of Strings, which is incorrect.

UITextField ignoring inputDelegate?

旧巷老猫 提交于 2020-01-14 07:25:20
问题 Does UITextField ignore the inputDelegate? Using the following code: - (void)viewDidLoad { [super viewDidLoad]; self.textField.inputDelegate = self; NSLog(@"textField: %@", self.textField); NSLog(@"delegate: %@", self.textField.inputDelegate); } I get the following output: 2012-03-26 20:43:49.560 InputTest[33617:f803] textField: <UITextField: 0x6c093a0; frame = (20 20; 280 31); text = ''; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x6c094d0>> 2012-03-26 20:43:49

How can I programmatically dismiss the autocorrect popover in a UITextView?

南笙酒味 提交于 2019-12-30 05:32:07
问题 I'm doing some custom auto-complete stuff on my own with insertText: , but if there's an autocorrect suggestion visible the view gets into a weird state. If I use [textView unmarkText] , it dismisses the autocorrect popup thingy -- but it accepts the autocorrection (which is bad). Is there some way to programmatically reject the autocorrect suggestion? My current "solution" works, but it's gross and hacky and I have no reason to assume it will continue to work in the future. Is there a better

MonkeyTalk not recognizing UITextfield input event [closed]

天涯浪子 提交于 2019-12-23 05:31:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am using Monkeytalk v1.0.62 and its not recognizing textfield input event inside the UIAlertview. If I type any text inside the textfield, it shows nothing while recording or in playback. It seems like the monkeytalk wont recognize UITextfield input or does it? 回答1: To record text input in UIAlertView text

UITextInput protocol usage for UITextField and UITextView to manage selection results in crash

白昼怎懂夜的黑 提交于 2019-12-22 09:55:17
问题 UITextField and UITextView both adopt the UITextInput protocol. UITextView's selectedRange property returns NSRange, where UITextField doesn't have any selection properties/methods. I'd like to use one routine to manage insertion in either UITextField or UITextView. So I do the following: id<UITextInput> textInput = nil; if ([self.aTextView isFirstResponder]) { textInput = self.aTextView; } else if ([self.aTextField isFirstResponder]) { textInput = self.aTextField; } if (textInput != nil) {

(# ゚Д゚) is a 5-letter-word. But in iOS, [@“(# ゚Д゚)” length] is 7. Why?

风格不统一 提交于 2019-12-21 12:33:03
问题 (# ゚Д゚) is a 5-letter-word. But in iOS, [@"(# ゚Д゚)" length] is 7. Why? I'm using <UITextInput> to modify the text in a UITextField or UITextView . When I make a UITextRange of 5 character length, it can just cover the (# ゚Д゚) . So, why this (# ゚Д゚) looks like a 5-character-word in UITextField and UITextView , but looks like a 7-character-word in NSString??? How can I get the correct length of a string in this case? 回答1: 1) As many in the comments have already stated, Your string is made of 5

Custom Input View in Swift

為{幸葍}努か 提交于 2019-12-20 14:19:32
问题 I've spent hours trying to figure out how to create/then get a custom inputView to work. I have a grid of TextInputs (think scrabble board) that when pressed should load a custom inputView to insert text. I've created a .xib file containing the UI elements for the custom inputView . I was able to create a CustomInputViewController and have the inputView appear but never able to get the actual TextInput to update it's value/text . Apple documentation has seemed light on how to get this to work

UITextField begin dictation

霸气de小男生 提交于 2019-12-18 05:41:54
问题 I'd like to programmatically put my UITextField input into dictation mode, without requiring the user to bring up and select dictation from the keyboard. Searched the API documentation but can find no solution. Any ideas? 回答1: This is currently not possible on iOS. The only place where it is kind of possible is in an app using WatchKit. In WKInterfaceController you can actually use presentTextInputControllerWithSuggestions with nil as parameter which starts dictation input immediately. 回答2:

Tap Gesture on part of UILabel

浪子不回头ぞ 提交于 2019-12-17 19:46:26
问题 I could successfully add tap gestures to a part of UITextView with the following code: UITextPosition *pos = textView.endOfDocument;// textView ~ UITextView for (int i=0;i<words*2-1;i++){// *2 since UITextGranularityWord considers a whitespace to be a word UITextPosition *pos2 = [textView.tokenizer positionFromPosition:pos toBoundary:UITextGranularityWord inDirection:UITextLayoutDirectionLeft]; UITextRange *range = [textView textRangeFromPosition:pos toPosition:pos2]; CGRect resultFrame =