How to populate a "Favourite" section in a UITableView - ios

I want to create a UITableView with 2 sections:
The first (upper) section lists entries from the second section that have been marked as "favourite".
*) The user shall be able to choose an entry, which results in the dismissal of the UITableView
*) Deselect an entry as favourite
The second (lower) section lists entries with a title and a subtitle.
The user shall be able to
a) choose an entry - which results in the dismissal of the UITableView
b) Select/Deselect an entry as favourite - which leaves the UITableView on screen, copying the selected entry into the "favourite" (first) section.
My questions:
Are there any best UI/UX practices on iOS to achieve this (IMHO rather standard) behaviour?
And/Or do I have to manually create a custom UITableViewCell with an UIImageView (for the "favourite" icon), and two labels (for title and subtitle), and attach a Tap gesture recognizer to the UIImageView?
I'd prefer not to create a separate "Edit" state for the table view, letting the user rearrange the order - all I want is either select an entry, or toggle favourite on/off.
Thanks

You can use the UITableViewCell accessoryView property to add your button / image view. You can use either a gesture or a target/action to be notified about selection.

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.

Passing data between UICollectionViewCells

I am using a UICollectionView, in which one UICollectionViewCell covers the entire screen. Inside my UICollectionViewCell, I give people the opportunity to add text (UILabel), images (UIImageView) and color (UIColor). Now when the user navigates to the next cell i want the color, labels and image views to be displayed exactly as they were added on the previous cell. The users also have the option to pinch and pan the labels and images. In short, how can i pass on data from one cell to another?
I see several ways how to do this depending on your realization:
use global properties/ivars to store the selected data from user input.
In either case you probably handle UITextFiledDelegate methods in your controller or extract the cell by indexPath and copy values from the current cell to the next one.
And when the user presses the "Continue" button you:
1) If you create all you collectionViewCells at once in cellForItemAtIndexPath, then you should only reload the necessary cell via - (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths and set the values you have saved previously.
2) If you create cells but the next one is not ready (for instance you save the memory) - all almost the same - you add a new cell to the collectionView and read the data from your properties.
3) If you have not a "Continue" button or/and user can swipe the cell in every moment - so you can reload the cell in scrollViewDidScroll(or scrollViewWillBeginDragging) or extract the existent by indexPath and modify it without reloading.

How to implement pick button

I'm creating UI for my application and i need to know how to implement pick button for IOS.
I have one row in my interface (height=44) for this purpose. So i think to create button and push segue to table with list of options.
When user taps button -> select option -> back to main view`, s/he must see selected option near the button (like table cell with details).
I don't know how to create custom button with 2 titles or something like this?
So what you do is subclass UITableViewCell and create a new cell with the button on the left and a UILabel for the select option. Then use that custom cell in your UITableView instead of the standard UiTableViewCell. When user taps button - take them to the options screen. Save their selection so that when you return to the main view, you can reload the UITableView with the selected option set.

UITextView Data Selectors Without User Interaction Enabled

I have a UITableView of custom cells that contain a UITextView.
I want the UITextView to have data detectors (so that you can tap on URLs), however, I also want the user to be able to tap on the table view cell to select it. With the data dectors, I must have user interaction enabled, but to select the cell when tapping on the UITextView, I must have it disabled.
Is there any easy way to go about doing this? Thanks!
Add a UITableViewCellAccessory (checkmark, disclosure indicator or others) to your cells. Then use the method tableView: accessoryButtonTappedForRowWithIndexPath: in order to detect click on the accessory.

How move/reorder cells from TableView1 to TableView2

I have several UITableViews, with different datasources in a iPad screen.
I need to copy/move a cell from the first tableView to the second, similar how is done with ListBox in other languages.
Now, I can reorder the cells, but the movement is restricted to the tableView. I want to drag the cell in tableView1 & drop in tableView2.
P.D. I'm open to use any other control to archive this. I take a look at AQGridView & DTGridView, however the layout is based in columns with different #items. If I can emulate columns with this controls or other then I can accept the workaround.
UPDATE:
I hope this links could help:
Observing pinch multi-touch gestures in a UITableView
This is the most close answer:
Drag and drop between two tables in ipad
I know how get a image from a view, I can detect the drag with a Gesture Recognizers, so I have all the setup in place but have not expertise in graphic development, so don't know how put this in motion...
This is definitely a very interesting question, and I wish I had the time to put together some test code to see if the idea I'm about to outline would actually work. My hope is that this will at least point you in the right direction.
UITableViewCell is a subclass of UIView, so I would create a subclass of UITableViewCell called something like DraggableTableViewCell so we can handle the touch events and then perform the following steps:
Create an instance of DraggableTableViewCell and configure it to appear like the selected cell.
Add the new cell as a subview of a view that is a common superview to both tables at the same location as the original cell.
Update the data source for the source table view and remove the original cell from the table view using deleteRowsAtIndexPaths:withRowAnimation:
Move the cell on the display by responding to touchesMoved:withEvent:
When touchesEnded:withEvent: is received, verify the cell is somewhat close to the other table view and determine the index path where to insert the new cell
Update the data source for the destination table view and call insertRowsAtIndexPaths:withRowAnimation:
Remove your draggable cell from its superview with a nice animation.
This entire process will need to be orchestrated by the view controller that controls the various table views on the screen.

Resources