UTextView autocomplete vs live suggestions iOS - objective-c

If I turn the autocorrection ON, the words get autocompleted, as if I write "wor", I get "word" before I finish writing. I don't want this to happen because I might be writing "world" or any word different than the autocompleted one.
I set Correction off in the Interface Builder and this problem is solved.
The problem now is that I still need the suggestions that appear in a little popover below the incomplete words.
This two features might be different but I don't know how to activate the suggestions.
How can I solve this?

This can be solved with the use of tableview. Create a tableview with the width as of the width of the textfield and height as you like. Place it just below the textfield. Make it hidden initially. When the user starts typing, fetch the array of data that resembles to the typed text and if any exists then, unhide the table view. On the subsequent typing keep on reloading the tableview sections with animations. You should be accurate on hiding, unhiding and then reloading the data on the tableview. I have implemented such thing before. It is really easy and once you get started with it you find it easy.

In the UITextView TextViewDidChange I created a thread that changed the cursor position. This, off course happens after the text view changes. The change of the cursor position triggers the autocomplete without letting me even see that there had been a suggestion.

Related

Text Editing with NSCollectionView

I've been banging my head against the wall (Cocoa) for about a week with this problem and wanted to get some advice if possible.
I'm trying to provide a list of NSTextFields to the user representing a list of features – letting them add additional textfields using an 'Add' button. This is part of a bigger form and the user should just be able to tab through the whole form (including the list)
I implemented the above using an NSCollectionView which pretty much worked except tabbing seemed to intermittently stop working in the NSCollectionView for reasons I can not figure out. You'll be hitting tab, cycling through normally when all of a sudden the collection view is skipped altogether, or sometimes if you're in a specific text field in the collection view hitting tab will just highlight the text but will never jump to the next field without mouse clicking outside the collection view. I was wondering if anyone had experienced this before... or has any advice for debugging something like this? I've attempted logging what the nextResponder is every time a control becomes the responder and there doesn't seem to be any pattern explaining why tabbing just stops working suddenly and then begins again.
There are 3 TabViews with a collection view in each. I have been wondering if that may be causing an issue?
Thanks for any help anyone can provide.
OK, after all this time I may have solved this (Tentatively anyway... I haven't seen any problems on numerous run-throughs and it usually occurs at least once every time before)
Turning on Auto Recalculates View Loop on the Main Window seems to have resolved whatever was happening. I have to admit I don't completely understand why, except that maybe because of the tab views and collections views the key loop needs to be recalculated to keep everything in sync. I'm thinking I need to do more research into exactly how the key loops work...

Extended NSTableView

I would like to make a table-view with expanding ability.
When you press a row, the row should expand to show options like delete, copy and so on.
I have found an example for iOS, but I didn't get it running on Mac OS X, because NSTableView and UITableView are very different.
http://www.cocoacontrols.com/platforms/ios/controls/kofiles
Has anyone another template?
Or maybe even get this example running on Mac OS X?
I don't have code to hand you but you can use a view-based NSTableView. Your prototype view can resize itself to include controls if it's selected. All that's a bit complex to condense into a reasonably brief answer but if you use a view-based table view and treat the prototype view like any other that would grow and show extra controls, then wire this behavior to the selection state, it should work.
Note: you will have to write some code for the expansion portion, to handle resizing it, showing the controls, and notifying the table view that one of its rows changed height. Lots of documentation and examples exist out there for each individual component of your problem. Post more specific questions as you run into roadblocks.

Resetting the selection cursor in a UITextView

I've looked at similarly titled questions, such as :
UITextView disabling text selection
but that wasn't quite what I was trying to achieve.
My app has a UITextView that only requires vertical scrolling. When holding down a touch, the cursor obviously appears at the point of the touch. However, when I change the text of the view, the cursor is always put at the end of the UITextView, which of course scrolls my text all the way to the bottom. I've tried setting the selected range, but even with the editable set to NO, this causes the keyboard to popup. I want my view to be able to display my text and vertically scroll, and to be able to reset its scroll position when I change the text. If I could achieve this and not be able to select, copy, paste, edit, etc. I would be perfectly content.
The last time I tried to deal with this I gave up and ended up using a UILabel, however I need to be able to scroll this time around. Would I be better off putting a UILabel inside a scroll view as a work around? Or perhaps releasing the textView would work, but since I have it hooked as a referencing outlet in IB, I imagine I would have to recreate it programmatically, and I'd like to avoid something so hacky if I can.
I'm at my whit's end with something I've always felt should be simple, so thanks in advance for any and all help!

Creating a view for user to fill up a form

I'm creating a view which provides some fields for the user to fill in - address, phone number etc.
I've seen apps that have populated fields with grey text like 'Fill in your name here' on the Name field, and when the user taps on it the text is gone, a keyboard appears and the view is zoomed in to the textfield(or whatever it is). Also, after filling up that field tapping the 'Next' button on the keyboard brings the user to the next field. I'm trying to do the same but I have no idea where to get sources on this. Pardon my poor googling skills ;p
Tried UITextView and UITextField but there isn't anything related to this on the Interface Builder. Figured it lies with the codes?
It'd be great if I can get some explanation or some links on how this works (: Thanks!
EDIT: okay I played around with the Interface Builder a lil more and realized I could set placeholder as the grey text.
It is in fact a UITextField.
You can get the greyed out text by setting its placeholder property.
I am not sure what you mean by zooming but usually they do use a scroll view or adjust the frame so that it isn't blocked by the keyboard.
The Next button is made available using a UIToolbar instance as the text field's inputAccessoryView. However the implementation is one's own and is not framework provided. You can look at this example to get started.

Changing how IKImageBrowserView indicates the drop position

I can make a single row IKImageBrowserView by setting the
[imageBrowser setContentResizingMask:NSViewWidthSizable];
but in this case while i drag an image inside image browser to rearrange it, the drop place highlights with horizontal line(vertical line expected).
how can this be changed?
Many thanks.
There is no defined way to do what you want.
You may be better off writing your own custom view where you can control every detail of how things are drawn. In general, Apple's controls are "as-is" and unless they provide an explicit way to control behavior or mention that you can custom an object in some way, don't count on being able to do it easily (if at all).
I would also suggest heading to http://bugreport.apple.com and making the enhancement request - it would be best if you attached a sample application demonstrating the behavior.
EDIT: You could also try out the NSCollectionView to see if it might work for you.