UITextView and position of floating autocorrect window - ios

I have a UITextView with autocorrection on. The view's height is about 30 pix. When autocorrect kicks in the autocorrect view is nearly invisible below the text. Is there a way to control the position of the small autocorrect window or insure it is the top layer so it is always visible and the user can easily see and interact with it?

I discovered that setting the scrollEnabled to false on the UITextView the popup would always appear above the word being corrected.

Did you try to set clipsToBounds=NO for your UITextView? Sounds like it's clipping the autocorrect view to the frame size of your UITextView..or perhaps auto-positioning it inside your frame. Worth a try anyway..

After trying various solutions unsuccessfully, I find the best way that worked for me is to simply add your UITextView inside a UIView.

Related

Text is not appearing when UITextView's content is more?

I don't need to scroll inside a UITextView so disabling a scrolling property of my UITextView.
It means UITextView's height is dynamic base on his content.
When I added more text in UITextView then text is not appearing.
It is working with less content.
As per my observation if height of UITextView exceeds 8100 then it stops rendering but not sure about it.
here is a structure of storyboard.
I understand your problem and please check below sample, i am modify your sample. This is working in my case.
Refer:- Updated Demo

IOS Keyboard with attached entry field

We use the IOS UIKeyboard to enter text into a UITextField which is positioned over our OpenGL View.
Is there a simple way to attach an entry field to the top of the keyboard, so it is within the frame of the keyboard and scrolls on and off smoothly with it, rather than moving your own UITextField when the keyboard scrolls on ? Maybe some property of the text field itself ?
Thanks
Shaun
You could put the whole view inside a UIScrollView
I think inputAccessoryView may be what you are looking for. It´s a property of UITextField.
See Documentation.

UITextView with links: disable scrolling, user interaction enabled

I've got a UITextView I'm using that has clickable links in it (ie, html links). I've set scrolling to be disabled.
By default "User Interaction Enabled" is false, and scrolling does not occur. However, in order to get the links to be clickable, "User Interaction Enabled" must be true. Given that, even with scrolling disabled, it is still possible to scroll the text if it exceeds the height of the UITextView.
My text is supposed to fit in the UITextView, so mostly this isn't a problem, however sometimes there is extra space at the bottom, and it cuts off a couple lines, and I don't want to ever allow that scrolling.
Is there a way to forcefully disable scrolling given these circumstances?
How about just disabling vertical scrolling via the UITextView delegate like this:
- (void)scrollViewDidScroll:(id)scrollView
{
CGPoint origin = [scrollView contentOffset];
[scrollView setContentOffset:CGPointMake(origin.x, 0.0)];
}
UPD:
1) As I understand you use textview just for displaying text with links, there are no editing or scrolling. If you add it using Interface Builder - make sure that you turned of editing, scrolling, selection options like on the screenshot. But selection might be on for URL detection.
Or do it in code using properties editable, selectable, scrollEnabled
2) If you want unselectable textview with URL - you might look for other control to archive this. Look at OHAttributedLabel, it is multi-lined and has link detection, and no text selection or scrolling.

Resizing UITextView with UIView below

I can't understand how create something like this:
The idea is the UITextView is resizing. But how to resize it when user enter 100 rows? I need to check /n and then increment frame by lineHeight and frame of cell?
Suggest pls.
No need. The text view should be resized to fit the keyboard. After that it scrolls the text if there is more text than fits into the visible part.
The path of least resistance to getting what you're describing to work is to create a method that updates the frames of the UITextView and UIView when the keyboard goes up or down. You know when the keyboard goes up and down based on UIKeyboardWillShowNotification and UIKeyboardWillDisappearNotification. The notification contains a userInfo dictionary that specifies the y-coordinate of the keyboard with respect to your view controller's window. All you need to do is recalculate your frames subtracting the height of the keyboard (either something like 216 or 0). If you still have questions about this let me know, and I'd be happy to explain further.

"Manually" handling text and cursor position of UITextView breaks when there are multiple lines

I have a narrow UITextView (about 1 line in height) to which I only add text programmatically, setting the text property of it as I click buttons. I also handle the cursor position manually, setting the selectedRange as the text changes. All works great as long as I have only one line of text.
When I have two or more lines of text and try to insert text at the first line, the text is inserted correctly and the cursor position is still at the right place but the UITextView scrolls to the bottom. When I then add another piece of text at the top it scrolls up to the "correct" position. This pattern then repeats for every entered piece of text at a line other than the last, making the UITextView scroll up and down for every button pressed.
I also tried calling UITextView scrollRangeToVisible: passing the selectedRange property as argument after setting the new text. That didn't work either.
I finally tried setting selectedRange after a 0.5 s delay after I set the text. Then it works as it should, but only after the UITextView has first been scrolled down to the bottom for 0.5 s. This seems to indicate that the setText method of UITextView is asynchronous in some way, and completes after I have already set selectedRange or called scrollRangeToVisible, and readjusts the UITextView to what it believes is the desired.
Can anyone tell me what is going on, and how I can get around the problem.
Thanks!
The auto scroll behavior of UITextFields can be annoying and difficult to harness at times.
Do you need the user to manually edit the text? If not, use a multiline UILabel.
If yes, also use a multiline UILabel and exchange it on the fly against a UITextView once the user taps. Change it back on didEndEditing. This techniques has worked well for me in table views.
I solved the problem!
When starting in the maze of creating a custom input view, I began implementing UITextInput and I found that the UITextInput protocol declares many interesting methods. And what is awesome is that UITextView implements that protocol. So even though it's not in the immediate UITextView API reference, you can call all UITextInput methods on your UITextView. For instance insertText: (from UIKeyInput protocol) and replaceRange:withText:. They made it much more flexible to programmatically work with a UITextView. Hope this can help someone else too!

Resources