I have to show keywords having a cross button in a textfield or textView. I am trying to get data from server that is keyword names that i want to show in a single line horizontally with a cross button on each keyword and can be disappear as soon as we hit on cross button. Any Help would be greatly appreciated. Thanks
What you need is an equivalent of the Cocoa NSTokenField (https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTokenField_Class/).
You should have a look to Cocoa Controls to find one that can suits you (https://www.cocoacontrols.com/search?q=tokenfield).
Related
This is more of a question of how to go about achieving it rather than a specific solution. I would like to have a label which allowed buttons and textfields to be inline and wrap to the next line. An example is the iOS shortcuts app where you can type in the same block as the text, and the textfield wraps along the same line. It is a textfield as there is a caret.
At a highlevel it might look something like this:
where each view follows the line and wraps to the next when needed.
I originally thought about using an NSAttributedString with links that were styled and the link could either act as a button, or open a textfield for input. I tried this and got something which worked but it did not resemble the iOS shortcuts app where the textfield is within the text. I have also thought about using textkit, but I have not gotten that far with this as I am not sure it is the correct approach.
Thank you for any ideas or solutions.
EDIT
I have thought about another way of achieving this but I don't know whether it would work either. The idea would be to use a collectionView of textfields. Some textfields would share the same LayoutManager so that the text is shared across the textfields. I would have to calculate how many textfields to create so that they flowed down the collectionView
In the image, Label 1 is made up of 1 textfield which has editing disabled. TextField 1 is made up of 3 textfields which have editing enabled and the three textfields would share the same LayoutManager. Label 2 is made up of 2 textfields with a shared layout manager, but editing disabled.
Using this approach would mean calculating how many textfields to create for each "Block" (Label or TextField) and updating this each time content changes. With this approach, I am only thinking of labels and textfields but the button can be added at another time.
I just started on this, but realised that sharing layout managers disables editing so I don't know whether this would be possible anymore.
Thanks
This is non trivial task for sure, and I don't think there's a ready-for-use solution.
Using NSLayoutManager you can calculate frames of each line/character of your text, and then forbid touches depending on these frames, and add background under editable text.
You have to use UITextView, because you gonna need to forbid user to select part of the text, and you can do it using something like willChangeSelectionFromCharacterRange:toCharacterRange: delegate method, and ofc you need shouldChangeTextIn: to forbid removing non editable text too.
I've been a long time lurker and want to start with a huge thanks to everyone. Now,
My main problem is that my client wants to show user selected tag's like in the image below
can I add multiple small views in a leftOverlay and if that's not possible can I add the selected tag word like a static text/placeholder and let the new search text start right where it ends ?
Thanks in advance
I think this can be implemented using UICollectionView and custom flowlayout. This can help you custom flowlayout
In my application i have a UIViewController in that one tableview with two custom cells,i want to display a floating button in my tableview.it is possible,it is possible give me some suggestion r link.
Thank you in advance!
"That question is not related to my question.i have a two custom cells with different heights in one tableview."
Answer is
Here is the simple solution for adding a floating button to our application.
we can add a button through "storyboard" like this
after adding the button create action what do you want.it's working fine.
thank you.
Coming from Android, I'm trying to learn coding on IOS, and it's really confusing.
What I'm trying to achieve is a scrollview that include a dynamic number of textfields.
You can add a textfield by pressing the plus button and remove the field by pressing the minus corresponding minus button.
But I have no clue about the best design for that. Can you give a lead ?
Something like:
Thanks !
Hello Im developing chat application. When I'm creating new group conversation, user is selecting in the tableview and I want to display selected contacts in textview above the tableview, exactly like in the Viber app.
But I dont know how to display text with background color in textview, also if u press backspace on the keyboard you don't delete just one letter but whole word. Can anybody please tell me how to do this?
Thank you.
Have a look at RMSTokenView, GCTagList or DWTagList. Seems to be exactly what you are looking for!
They both let you use custom fonts and gradients.