How to add a text field to the end of a UICollectionView - ios

I'm implementing an entry field where users can enter tags. Once a tag is recognized, it is replaced by a UICollectionViewCell that makes the tag look prettier.
It looks something like this:
Now I would like to add the possibility to add another tag by just typing after the end of the current list of tags. Is there a way to do this? I was thinking of adding a cell with a UITextField in it or something similar, but that would create problems if I had to do line wrapping, since there might arise a situation where the user would've entered the first two tags on the picture above, and then I'd want a cursor to appear right after them. However, this would require adding a cell that would not be rectangular (if the user filled the entire first line, it'd have to wrap back to the beginning of the next line).
How is this usually done?
To clarify, if I added a text view to the end and the user entered something spanning multiple lines, it would probably wrap like this:
TAG1 TAG2 XXXXXX
XXXXXX
XXXXXX
XXXXXX
Instead of wrapping like this:
TAG1 TAG2 XXXXXX
XXXXXXXXXXXXXXXX

Try this one here. There are other tag controls that might be suitable. Just browse this site, its quite resourceful and free.

Related

Using an inputfield as a shorthand commandline for Ruby on Rails

I would like to have an input-field on my webpage, which allows users to interact with models and perform specific searches within specified models. The system should support various actions, primarily add (+), delete (!) and search (?).
To add a new Todoitem to a todolist, the syntax would be like this:
+todoitem Some text here #todolistname
To delete a post, the syntax would be like this:
!post nameofpost
To search for a post, the syntax would be:
?post nameofpost
The previous examples adds and removes items from the current signed in user. I would also like the command line to support groups (identified by .groupname)
A valid syntax to add a todoitem to todolist with name important
ingroup school would be: +todoitem Some todo text #important.school
Searching for all posts in a group would be: ?post .group
Spaces and order should not matter, except for actual content to be added to model (like the todo text of a todo item). That means +todoitem.school#important Some todo text should give the same result as the input in #1.
Could anyone help me with a way of implementing this effectively in rails? That is how you could effectively search the input-string, decide what the user is trying to do (based on the prefix identificators), and then parsing the input into actual queries ?
Edit:
To clarify the last paragraph, as I might have misused the word 'parsing', I was thinking of going through the input-string letter by letter, and then branching/dividing the information so that it can be easily used by pre-defined functions (which perform the queries).

ios/xcode/coredata: How to mimic ajax call in objective c

For a tag system, when entering a new item, I'd like the user to start typing a letter or two and see possible tags...similar to how SO tags work on the website i.e. Ajax.
Is there a way to do this on IOS?
Basically the Add Item screen has some empty text fields where you put the name etc.
I'd like to have an additional empty field where as you enter letters you see possible tags appear below and can then select one to tag the item.
The tags would be served from an entity or table so there would have to be a call to core data to supply them based on the letters typed.
Do I have to implement a full blown tableview to do this? Or is there a way to make the possible tags show up below the textfield box.
Thanks for any suggestions.
You could try a third party development in order to make what you want. In a recent project I have used this one:
https://github.com/EddyBorja/MLPAutoCompleteTextField

Creating control for hashtag listing with Swift

I a bit confused on this subject, and I'd like your help and thoughts on this. Basically I need to create filtering through my API by hashtags (for example cites). I could just put them like ordinary text in a UITextField that is separated with spaces and run API request with them, but that looks lame. Control I'd like to create is similar to this one (this is you something I created in PS).
So, I need way for users to add tags to this box in very simple fashion like presented above, and create a way users can delete them by clicking a x button inside tag box.
In ideal situation I would like to be able to access tags from this control using NSMutableArray that is control property.
I'd like you to throw ideas and write how would you implement such control.

Editable blocks on page (not related to model - related to SEO) in Ruby on Rails

My SEO-people do not write code. All they love is creating good texts. All they can do is pasting texts do database via some nice forms.
The problem is that sometimes they ask me: we need to put the text into page footer. Wee need to put some other text into page header.
And I just can not edit the code every time SEO-man asks me!
And sometimes the text are not related directly to model. I think you will understand me that it is a bad idea to create footer_block field inside a Car or Person model.
How nice it would if there was a gem that could:
Load text data from database by key (for example 'FOOTER_BLOCK'). To let me not to turn the models into a mess!
Give us forms where a SEO-person could paste the text
(Would be nice) Give us a WISIWIG editor.
PS: An example of such functionality (but not in Ruby): I used to code in python/Django. And we used django-flatblocks package - it did fit these 3 criterias.
I don't know any gem which will do this, but hopefully I can shed some light on how you might be able to achieve it
Code Blocks
You could create a table (and model) called code_blocks. The schema may look like this:
code_blocks
id | title | body | created_at | updated_at
This will allow you to create any number of records in this table that you want, and then call them from your app without the need for specific controller actions
Display
You could do this:
#app/helpers/application_helper.rb
def code_block(id)
block = CodeBlock.find(id)
return block.body
end
This may be inefficient, but it will allow you to include the code blocks whereever you want on the page, independent of the controller actions
So, for example, you have a footer block with id as 3, you could put:
<%= code_block(3) %>
Editing
This will mean that if you have a simple backend form, you can set it up so that you list the blocks by title, and allow the SEO guys to edit the HTML with a WYSIWYG editor (saving the HTML in the body column)

How to create a tagging system like on Stack Overflow or Quora

I want to create a tagging system like seen here on Stack Overflow or on Quora. It'll be its own model, and I'm planning on using this autocomplete plugin to help users find tags. I have a couple of questions:
I want tags to be entirely user-generated. If a user inputs a new tag by typing it and pressing an "Add" button, then that tag is added to the db, but if a user types in an existing tag, then it uses that one. I'm thinking of using code like this:
def create
#video.tags = find_or_create_by_name(#video.tags.name)
end
Am I on the right track?
I'd like to implement something like on Stack Overflow or Quora such that when you click a tag from the suggested list or click an "Add" button, that tag gets added right above the text field with ajax. How would I go about implementing something like that?
I know this is kind of an open-ended question. I'm not really looking for the exact code as much as a general nudge in the right direction. Of course, code examples wouldn't hurt :)
Note I am NOT asking for help on how to set up the jQuery autocomplete plugin... I know how to do that. Rather, it seems like I'll have to modify the code in the plugin so that instead of the tags being added inside the text field, they are added above the text field. I'd appreciate any direction with this.
mbleigh's acts_as_taggable_on gem is a feature-complete solution that you should definitely look into a little more closely. The implementation is rock-solid and flexible to use. However, it is mostly concerned with attaching tags to objects, retrieving tags on objects, and searching for tagged items. This is all backend server stuff.
Most of the functionality you are looking to change (based on your comments) is actually related more to your front-end UI implementation, and the gem doesn't really do much for you there. I'll take your requests one-by-one.
If user inputs a new tag, that tag
gets added, if user inputs an
existing tag, the existing tag gets
used. acts_as_taggable_on does this.
Click a tag from suggested list to
add that tag. This is an
implementation issue - on the
back-end you'll need to collect the
suggested list of tags, then display
those in your presentation as links
to your processing function.
Autocomplete as user enters
potential tag. You'll use the jQuery
autocomplete plugin against a list
of items pulled off the tags table.
With additional jQuery, you can
capture when they've selected one of
the options, or completed entering
their new tag, and then call the
processing function.
Restrict users to entering only one
tag. This will be your UI
implementation - once they've
entered or selected a tag, you
process it. If they enter two words
separated by a comma, then before or
during processing you have to either
treat it as one tag, or take only
the text up to the first comma and
discard the rest.
When you process the addition of a
tag, you will have to do two things.
First, you'll need to handle the UI
display changes to reflect that a
tag has been entered/chosen. This
includes placing the tag in the
"seleted" area, removing it from the
"available" display, updating any
counters, etc. Second, you'll need
to send a request to the server to
actually add the tag to the object
and persist that fact to the
database (where the taggable gem will take over for you). You can either do this via
an individual AJAX request per tag,
or you can handle it when you submit
the form. If the latter, you'll need
a var to keep the running list of
tags that have been added/removed
and you'll need code to handle
adding/removing values to that var.
For an example of saving tags while editing but not sending to server/db until saving a form, you might take a look at the tagging functionality on Tumblr's new post page. You can add/remove tags at will while creating the post, but none of it goes to the database until you click save.
As you can see, most of this is on you to determine and code, but has very little to do with the backend part. The gem will take care of that for you quite nicely.
I hope this helps get you moving in the right direction.
The more I try to force the acts-as-taggable-on gem to work the more I think these are fundamentally different types of problems. Specifically because of aliases. The gem considers each tag to be its own special snowflake, making it difficult to create synonyms. In some cases it doesn't go far enough, if you want the Tag to have a description you'd need to edit the given migrations (which isn't hard to do).
Here's what I'm considering implementing, given the trouble I've had implementing via the gem. Let's assume you want to create a tagging system for Technologies.
Consider the following psuedo code, I haven't yet tested it.
rails g model Tech usage_count::integer description:text icon_url:string etc. Run the migration. Note the
Now in the controller you will need to increment usage_count each time something happens, the user submits a new question tagged with given text.
rails g model Name::Tech belongs_to:Tech name:string
Name::Tech model
belongs_to :tech
end
Then you could search via something like:
search = Name::Tech.where("name LIKE :prefix", prefix: "word_start%")
.joins(:tech)
.order(usage_count: desc)
.limit(5)
This is starting point. It's fundamentally different from the gem, as each tag is just a string on its own, but references a richer data table on the back end. I'll work on implementing and come back to update with a better solution.

Resources