I'm building an app that pulls data from internet (events) then it displays all the events in a tableview (different sections based on dates).
If user clicks on any event it expands, and then they can favourite the event or event host. How i can reorder my table to show those favourited events first. Because i didn't build my app with any in app "data model", what i mean is that all the data displayed in the tableview (ordering) is based on the pull request, what ever comes first is displayed first.
Are there any way to force some certain cells to top of the section? Manually reorder the cell's in code in my situation?
And one other question? I'm using section headers (dates) , but can i have two headers so it's (Header)date - (subheader)city - (cell)event. Or am i limited to only one section header?
Related
In my App's UITableView, when user swipes to delete an item, the App deletes not only the selected item but also other related items in the data source, which may be shown or not shown on the screen at the time. My first thought was that I need to iterate all cells in the UITableView to get the cells for those data items and call UITableView.deleteRows() to delete them. But a quick search on SO showed that it's impossible to iterate all cells due to the way how UITableView works.
So I wonder what's the right way to synchronize UITableView with data source in my case? Is it OK to just iterate UITableView.visibleCells? But if I understand it correctly, UITableView prefetches (I mean it gets more items than it needs to show on the screen) for performance reason, so what if the data item I delete are among the items that are prefetched by UITableView but are not shown yet? Should I call UITableView.deleteRows() to delete them too? But how can I get those cells?
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.
I have an indexed table view in which the cells are grouped alphabetically into sections. I would like to be able to only load a block of the data associated with a particular section when that indexed section is selected. In other words, my table view is the type where there is a selectable field at the right side of the table view that contains the letters A-Z. You can select the letter P for example to jump to cells that have content that starts with the letter P.
Is there any way to detect the selection of an indexed section so that I can then reload the cells in that section once I load the block of data associated with that section?
As the user uses the index down the side, the UITableViewDataSource tableView:sectionForSectionIndexTitle:atIndex: method will be called.
You can add logic to this method that if this is the first time you've seen a given section index, that you need to load the data for the section.
But keep in mind that long before this you would have already told the table how many total sections there are and how many rows are in each of those sections. So long before your table even shows the index down the side, you need to have at least loaded counts for all of the sections but not necessarily the detailed data.
Also keep in mind that a user can slide their finger down the index list. This means the table will want to jump to each and every section as the user slides their finger. So whatever lazy loading you do needs to deal with this in a nice manner (not making the UI sluggish).
I am building an app that will have it's own list of 'contacts'. It will not be connected to the device's actual contacts app.
However, I want to basically imitate the Contacts app 100%.
That is, have a table view to display user info (done!) and allow a user to edit the user info and have the table view "animate" into a slightly altered table (just like the Contacts App does!).
How does the Contacts app work when it comes to the "transformation" of the table when going into edit mode?
It is all in the UITableView documentation:
When sent a setEditing:animated: message (with a first parameter of
YES), the table view enters into editing mode where it shows the
editing or reordering controls of each visible row, depending on the
editingStyle of each associated UITableViewCell. Clicking on the
insertion or deletion control causes the data source to receive a
tableView:commitEditingStyle:forRowAtIndexPath: message. You commit a
deletion or insertion by calling
deleteRowsAtIndexPaths:withRowAnimation: or
insertRowsAtIndexPaths:withRowAnimation:, as appropriate. Also in
editing mode, if a table-view cell has its showsReorderControl
property set to YES, the data source receives a
tableView:moveRowAtIndexPath:toIndexPath: message. The data source can
selectively remove the reordering control for cells by implementing
tableView:canMoveRowAtIndexPath:
You also use the UITableViewDelegate methods to set up how rows appear in editing mode
– tableView:editingStyleForRowAtIndexPath:
– tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:
– tableView:shouldIndentWhileEditingRowAtIndexPath:
And these methods from the UITableViewDataSource:
Inserting or Deleting Table Rows
– tableView:commitEditingStyle:forRowAtIndexPath:
– tableView:canEditRowAtIndexPath:
If there is something specific you are not sure about please ask something specific.
I am using a standard grouped style UITableView that returns a custom header view for one of it's sections (using the tableView's delegate method viewForHeaderInSection:). The view that is returned for the section header contains a control. It displays an image and is a control so it can tapped to let the user change the image. My desired UI is similar to the photo for a contact in the Apple Contacts app (a floating imageView-like control in a grouped style table).
The problem I'd like to solve is that touches on the tableView section header go straight to the control. I'd like the table to get a chance to determine if the touch is actually the beginning of a scroll gesture. If not, then the table can pass the event to the section header view for processing.
This is how all the rows in the table behave since I have "delaysContentTouches" for the table on. I suspect the problem is because the section header view is not in the table's view hierarchy. So everything is probably working per spec. just not the way I want.
I want the section header view to behave regarding touches just like rows do (table gets first chance to process).
BTW I am not placing this control in a table row (which would solve the problem) because I want the rounded rect grouped style for all table rows, but not for this one UI element. This control is in the center of my table (header for section 1) which is why I want drags on it to scroll the table.
OK, so apparently this is simulator issue only. On a device my tableView gets the first chance at the event. So I guess I need to listen to the Apple mantra of "always test on an actual device" before posting to StackOverflow. Sorry friends... may my error be helpful to others who, like me, probably spend too much time in the simulator.