First button of UITableView as Search as well as Add textfield - ios

If you see the screenshot below, its a view from iOS Files app which lets you select tags for a file.
I want to make a similar Tableview which lets user either select existing items or add new items. But I also want the add textfield to be a search field. That is, when the user starts typing there, he also gets search results from the existing items.
The way I am planning to implement this is...
Two table views.
One has a static cell to 'Add' and is not vertically scrollable.
Right underneath is the second table view with existing itmes, which is vertically scrollable.
when the user taps and starts typing in the textfield, there is a search side by side, in the second table view and the user can select an item from it as well.
When there are no matching results, an add button is highlighted and the user can add a new entry.
I want to know what is the best way one can implement such behaviour?
Also,
(In terms of UI Design)
Should one make use of the UISearchBar instead of a textfield?
Or, is it better to simply use the UISearchController?

Related

Can I choose only portion of a row in UITableView to be clickable(selectable) in Swift?

So I have a table in the accordion style. When a row is clicked, five radio buttons are displayed. Then, users should be able to click on those buttons. It successfully displays the buttons, but when the buttons are clicked, instead of highlighting the selected button, it shrinks the row itself. I think this is probably because I implemented each set of the label part and the option part as a single row, just in different UIViews. I believe clicking on the view that contains buttons is overridden by clicking on the row(label + options). Its really hard to explain, but I think a solution could be restricting selectrow action of the table to only certain portion of the row.
Is there a way I could achieve this? If I cannnot, is there other ways to implement the accordion table to be used as I described?
I am having a really hard time trying to explain this. If you have any questions, please let me know.
table
As per my understanding you van give a try to below steps:
Disable the row selection so that you can avoid row selection. Usecell.selectionStyle = .none
Secondly for your button in row set the IBAction in controller class and in Storyboard connect those actions to specific buttons.

Using storyboard to create multiple TableViews that can be toggled between using a button

I'm trying to create an app where multiple lists can be switched between using a button. Does anyone have any advice on the best way to do this, preferably using storyboard (my Swift skills leave a lot to be desired)? Right now I only have one list (a TableView) which is contained in a Container View, along with two other regular Views, one at the top and one at the bottom of the Container View, with the TableView in the middle. I want to have a button in the top regular View that switches between multiple TableViews. I want the number of TableViews to be dynamic, starting with one, but then the user can add additional tables as they need. Any advice on how to set this up would be greatly appreciated! Is it even possible to create a prototype TableView? Is that the way to go here? I've found a couple of Answers on Stack Overflow regarding multiple tables on a single screen, but these lists wouldn't be on a single screen, they would only be viewable one at a time: if you want to see the second list, you have to press the "Next List" button (in the View at the top of the Container View), and the first list disappears and is replaced with the second. Thanks everybody!
Don't change table views, change datasources. Use a single table view as you have it, and one array for each mode that the table is in (call those arrayA and arrayB). Another array-type variable -- call it theModel -- should be set to point to A or B.
The datasource methods will answer the count of theModel, and get values for the cells from theModel. When the user presses the button...
self.theModel = (self.theModel== self.arrayA)? self.arrayB : self.arrayA
self.tableView.reloadData()
// everywhere else, use theModel as the datasource

Editing a UITableView that contains dynamic data in each row?

I have a UITableView that is separated into sections with one row each. Each row contains a horizontally scrolled UICollectionView. I am wanting to add the functionality for editing this list when I tap a general edit button in the top of my Navigation Controller. The issue that I'm thinking of is that all of the content will still move around and be active (tapping on a cell in the CollectionView will open a different page). I am wanting the edit mode to either disable that functionality or slide all of the content over simultaneously and have an edit button next to them all. When this edit button is pressed it will take the user to an edit page specific to that rows content (so no delete functionality here). Another reason why I am having a difficult time is that all of the content in the table will be loaded via data so I don't want to reload any of it.
Bottom line is that I need to select a single row and it must be done via a button that slides in or altering the functionality of the content there to act as a button. I cannot reload the data in the rows, though because it is loaded via internet data.

how to connect textfield with table view of listed options instead of keypad

I need to be able to disable the keypad in a textfield, and instead when the user taps on it to start editing, a new table view will appear presenting a list of possible strings with which the textfield should be filled.
Anyone has any suggestions on how to achieve this?
Thanks in advance
p.s. I tried already but this functionality cannot be nicely implemented with a picker in my case, as there are too many options to choose from and (more importantly) each one of them is a rather long string and cannot appear entirely in a picker.
I believe you just need a regular cell that, when tapped, pushes a new detail UITableViewController with all the options to choose from. Once an option is chosen, set the cell's textLabel to whatever option have been selected.
If you'd like to go for an easier path, then you should also probably check the free Sensible TableView framework, as it has these kinds of cells out of the box (called selection cells). You just pass on your strings array to the selection cell and it will automatically display the detail view, and even assign the selected option to one of your object's properties if you wish. Should save you some good amount of manual work. Good luck!

Table View Design Issue

My app design required a page that display 'user information' and i currently have this setup using a simple table view in a View controller. Now, the tricky thing is I need to be able to provide functionality to the user to be able to edit these on the same same screen. So essentially when the user taps on a row in the table view, I want that little flashing text line at the end of the current text in the row so the user can edit what's currently present and I also want a save button to apear on the top when a user has started editing. The tricky part is, not all fields in my table view will be editable. So, I need certain fields to be editable and have the save button appear and certain fields not.
Can you tell me how would I go about modifying my existing design to implement this functionality? I would appreciate some code if you think you can show me how exactly I would go about doing things.
You would probably want to make some custom UITableViewCells. You can fill a tableview with all sorts of different cells which are different sizes and looks different, all at the same time. I would suggest a custom UITableViewCell which will hold a UITextField as one of the subviews. On the cells which you don't want user interaction with the textfield, either make a new custom cell that uses a UILabel or just do textfield.userInteractionEnabled = NO. Look up some custom uitableviewCell tutorials to get you started and then use the approach that I suggested for your problem.

Resources