uitextview

Is there a way to have iOS' autocorrect ignore a single word or regex in a UITextView?

限于喜欢 提交于 2020-01-21 07:00:47
问题 I'm building a textview to compose status messages, and one of the functions it has is to include #hashtags within the text of a status message. However, these #hashtags often aren't actual words , so iOS' autocorrect functionality causes them to appear with a red underline once the hashtag has been typed. (For example: #seafair2014, #wwdc, and other non-word hashtags) Is there a way to temporarily add a term to the iOS dictionary, so as to ignore any #hashtag or @username typos but still

Show more button next to end of text Swift

会有一股神秘感。 提交于 2020-01-21 05:00:08
问题 I want to show more button at the end of the text or below if there isn't enough space. I don't understand how Apple developers did this? Please answer in swift. After clicking on more button i want to show all the text. change the button to less. Thanks in advance. 回答1: Here's a great CocoaPod for the functionality you're looking for. https://github.com/ilyapuchka/ReadMoreTextView This will allow you to set a maximum number of lines and customise the text append to the end of the trimmed

Only first link is detected in uitextview

爷,独闯天下 提交于 2020-01-17 11:14:46
问题 I have strange problem with url detection in textView. My code is like this: _contactDescription.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber; [_contactDescription setUserInteractionEnabled:YES]; [_contactDescription setSelectable:YES]; [_contactDescription setEditable:NO]; _contactDescription.delegate = self; _contactDescription.text = desc; My string has a lot of phone numbers and emails to detect but using data detection only first phone and first email run

Only first link is detected in uitextview

℡╲_俬逩灬. 提交于 2020-01-17 11:13:09
问题 I have strange problem with url detection in textView. My code is like this: _contactDescription.dataDetectorTypes = UIDataDetectorTypeLink | UIDataDetectorTypePhoneNumber; [_contactDescription setUserInteractionEnabled:YES]; [_contactDescription setSelectable:YES]; [_contactDescription setEditable:NO]; _contactDescription.delegate = self; _contactDescription.text = desc; My string has a lot of phone numbers and emails to detect but using data detection only first phone and first email run

Aligning text vertically center in UITextView

為{幸葍}努か 提交于 2020-01-17 04:47:07
问题 I am setting some attributed text to textview, and giving line. I am trying to set baseline alignment vertically center but unable to set that. How can I set the text vertically center in textview. 回答1: First add/remove an observer for the contentSize key value of the UITextView when the view is appeared/disappeared: override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) textView.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.New,

Non-Editable UITextView Left-Aligns RTL (Arabic, Hebrew, etc) Text

和自甴很熟 提交于 2020-01-16 02:11:41
问题 Using iOS 5.0+ for iPad, I have an app with containing Arabic text in a UITextView where: myTextView.editable = NO; Strangely, the Arabic text suddenly aligns to the left and not the right, causing quite a problem for user readability. I appreciate any help overcoming this strange behavior! 回答1: Solved it! Turns out it's very simple: just set the textAlignment to UITextAlignmentRight. UITextView works differently when editable and not, especially when it comes to RTL text. If the base writing

How to detect undock, dock or split is pressed on iPad (iOS 5)

那年仲夏 提交于 2020-01-14 14:31:29
问题 I am trying to detect dock key is pressed or not on my iPad. This dock key is a new feature in iOS 5. When this key is pressed the keyboard disappears. I need to detect it. When this key is pressed I need to change the frame of my view, but I couldn't get any event by pressing this key. I am trying to use the following function: - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { NSLog(@"TEXT: %@", text); return YES; } When I

weird positioning of the cursor in the UITextView

不羁岁月 提交于 2020-01-14 09:22:07
问题 I am writing from scratch growing UITextView in my swift app. I put a textView on the view like this: it is right above the keyboard. The textView has constraints attached to the view : leading , bottom , top and trailing , all equals = 4 . The view has the following constraints: trailing , leading , bottom , top and height Height is an outlet in my code. I'm checking how many lines are in the textView and based on that I'm modifying height : func textViewDidChange(textView: UITextView) { /

Can I Programmatically Select Text in UITextView?

强颜欢笑 提交于 2020-01-12 05:46:26
问题 I want to select Text on UITextView, similar to the default "Select" and "Select All" pop options we see when we tap. I want to the user the ability to do that from my custom menu. I played with selectedRange but that doesnt seem to do the trick. Any ideas? Thanks 回答1: The selectedRange property should do it but, as mentioned in the documentation, only in iPhone OS 3.0 and later. In 2.2 and earlier, the selectedRange property is actually an insertion point. 回答2: As mentioned in the accepted

How to hide keyboard - of - UITextView iPhone - by return Key [duplicate]

我怕爱的太早我们不能终老 提交于 2020-01-12 04:49:11
问题 This question already has answers here : How to dismiss keyboard for UITextView with return key? (33 answers) Closed 6 years ago . In a UITextView, when we click on it, A keyboard appears, but when user press return key, (normally creates a new line in textView) keyboard should go down. How? 回答1: Ok i have found the correct answer by the help of @jordan - link help. Implement following code to your view controller .m file & .h file add delegate -(BOOL)textView:(UITextView *)textView