I want to set two different UITableview in single UITableview's particular section. Is it possible??
To do exactly what you are asking is not possible. but I think that you did not phrase what you want correctly.
You probably want to show data from 2 different table views in one section. As you probably know each tableView has a Data Source. All you got to do in order to show data from the 2 tables is to manipulate the Data Source to return exactly the data you are expecting, i.e. joining the 2 data source content for this section together.
Related
I am working in a table with multiple data inside. When I add only the header, I can see the data in a good way, and the columns with different sizes.
But when I add the data, all the columns go crazy, the widths are adjust to the headers, and the data dissapear.
How can I get to show every data in the proper way?
You need to derive table and override the method to create a cell then after a call to super set it to not end with 3 points.
You can also override the create constraint method and define percentages for the specific columns although this might not look good for all resolutions.
As a side note we made quite a few improvements to Table in Codename One and integrated basic Asha support as well.
Right, so my UITableView loads and puts all the cells in Alphabetical order. Information is then downloaded from a server and calculations are done, with the TableView being reloaded once everything is complete. Currently this is quite a simple procedure as once the information is downloaded from the server, the cells don't even move, they are left in their alphabetical order. Nothing really happens other than half of the information is filled in and small changes are made depending on the calculations. I was wondering if there was an easy way of putting the cells into sections depending on the calculations done after the download is complete? I did have an idea of creating 4 arrays (there will only be 4 sections ever) and once isLoading is set to no, changing the data source of the TableView to have sections, however, that sounds a bit... iffy. I know this is a theoretical question as opposed to a coding problem, but before I go and mess up my code, in what is sure to be a stupidly inefficient way of doing things, is there an easy way of "assigning" UITableViewCells to sections?
My main issue with my way of doing it is that should the user delete a cell, deleting the appropriate entry in Core Data will be a little tricky and prone to errors. This lead me on to another idea. What if I added an extra attribute to my Core Data entity. That attribute would be assigned and then saved once the calculations were done. The problem with this is that no existing databases would work. There has to be a neat way of achieving this.
Thanks for the help. If you need me to post any code just say so and I will.
You should be fine if you implement the data source methods related to sections.
For example:
numberOfSectionsInTableView
sectionIndexTitlesForTableView.
Any time the table data is reloaded (e.g., [self.tableView reloadData]), these methods will be called and the data will be placed into their sections.
Keep in mind that the cells are just the visual representation of your model, which in this case is your fetched data. The cells are not assigned to sections; they are simply created however you specify for your model (via the table view data source and delegate methods).
Regarding deletion of entries while using Core Data, I suggest taking a look at NSFetchedResultsController. The latter will monitor any changes to your table's data and message its delegate, your table view controller, when updates are made.
For example, a deletion would start with a call to the table view delegate like normal (i.e., via tableView:didEndEditingRowAtIndexPath). Within the latter, you would then delete the entry from core data (e.g., [self.myDatabase.managedObjectContext deleteObject:entity]). Assuming you initiated the NSFetchedResultsController w/ the same managed object context, the deletion would be automatically reflected back to your user.
If you're using a remote DB, however, you'll also have to perform a save (however you've implemented that) to ensure the DB is updated too.
Note also that if you use an NSFetchedResultsController, you don't need to implement the section data source methods since NSFetchedResultsController can handle that for you. Just define the key-path in your data model that will return the section name when initializing the NSFetchedResultsController.
I am having a view to display a list of Shops within a UITableView.
The user should have the possibility to modify the shops displayed by some filters.
For example it should be possible to display the shops ordered by name (with the first letter as section header). Further the user should be able to display just the favourites or sort the shops by category (category name is section header):
I did not want one table view, handling all the filters because I thought it would be a mess of if-then-else tags depending on the current filter. So I decided to create 4
UITableViewControllers with each of them handling one filter.
That's exactly what I need, no redundancy so far, because the tableVC delegate and datasource methods are the ones which need to be implemented differently.
But now I do need a header which appears depending on the scroll position of the table. This is exactly the same in all of the 4 tables. But how should I solve this issue now?
Implement the UIScrollViewDelegate methods in each of the four UITableViewControllers redundant? Create a ParentViewController handling the scrollView methods (which would not be so easy because of the table datasource and delegate methods...
Any suggestions how to solve this properly? How would you do this?
I would appreciate any help, thanks in advance.
I would create a parent class, taking care of the header and derive the UITableViewControllers for the filters from it.
The superclass takes care of the common elements (like the header), the subclasses take care of the actual display.
Alternatively, you can create an overloaded method, which returns an Array of cells to display.
Store this array and when the delegate (in the superclass) asks for the 'cell data', give him the corresponding element in the array.
First post. I'm still reading the iOS Human Interface Guidelines and haven't come across this scenario, yet. When displaying multiple columns in a table, what is the appropriate indicator to the user that they can change the column used for sorting?
Well, the UITableView is a one-column table. So, you can usually not change the sorting. I'd recommend reading the Table View Programming Guide. It says right at the beginning:
A table view has only one column and allows vertical scrolling only. It consists of rows in sections. [...]
I have the same challenge. I'm showing a single list of customers, each having a unique number and a descriptive name. I've added a segmented control to the middle of my toolbar that allows the user to sort by name or number.
Normally to use UITableView, the number of sections and rows per section are known. But what if they aren't? I want to implement a lazy search, so that I actually search for the next match when new data needs to be displayed. Something on the lines of: db.prepareSearch(query) and then call something like db.nextSearchResult() when it is time to display a new cell. The search result determines if a new section is required or not (search results are inherently sorted).
Not sure why it wasn't done this way to begin with, so that it asks for a section until no more are available or needed, and for cells in the section until no more are available or needed, instead of having to specify the totals, which implies having to finish the whole search before starting to display the first few results.
To get the number of sections and rows, it's easy -- ask your data source. If your data source has no way of telling you this, make a way.
For instance, if you have to query a table and ask how many rows there are for your sections, do that. Then, for each section, ask how many rows there are which match that section.
What it also sounds like is you want to paginate your data. Meaning when you get to a certain point, have a "load more data" cell or some-such. This is fine too, just add a sentinel node to your data source, and whenever that particular item comes up, display your alternate cell while you load your data, then remove it after your next data is fetched. I do this in a few of my apps.
If I'm understanding this correctly, at the point of drawing/populating, you will know how many rows/sections you have.
If your changing the underlying data using db.nextSearchResult() then you must be calling [tableView reloadData] to trigger a UI update, at this point you should know how many sections and rows you have.
I have to admit I'm a little confused to the exact issue here.