With IOS, is there a way of making a proper table with rows and columns? - ios

I have been trying to find a way of creating a table, with rows and columns, for iOS. The UiTableView is basically a tree-structured list like this
Apple sample code, but because it's called a table view, it hijacks any attempt to search for a proper table.
There are a couple answers that suggest very clunky ways of doing it, like this SE Question, but it's quite old. Has the situation changed since this question was asked?

I've done this using UITableView by simply designing custom UITableViewCells that are segmented into columns. All the custom rows together certainly give the appearance of a multi-column table. When any of your data in a column or row updates, you re-render the tableView or have each row in charge of its own re-rendering (i.e. via an NSNotificationCenter message), and the whole experience for the user is as a multi-column table. If you setup your table's data as a separate row-column data model, it's pretty easy to get all the individual cells to go where they need to go with your custom UITableViewCell.

take a UITableView and on tableRow take 3 view of(width=1 and height=row height), each view ill be at equal distance from another one. and take label between these view at end it ill look like a table with rows and column

Related

Table with rows and columns in Objective-C for iOS

How can I implement a table with rows and columns in Objective-C? I need to show a timetable: columns for week's day and rows for hours. I have no idea. TableView makes rows. Would UICollectionView be right for this?
You can use UITableView. But instead of using the default UITableViewCell, you have to create a custom cell with 7 labels equally spacing horizontally. Then you add 24 rows, each for one hour. And I think that's all you need, simple and straight forward.
That depends on how you want to eventually display it. What I usually do is create an array ( or two, or three if needed) and then pull from that when I want to display parts of it. The reason I said I might need one or two is that one might be for strings and another might be for for integers or float values. It all depends on the situation and you have to make sure you keep them synchronized programmatically.

Multiple columns in tableview ios

I am working on an app using objective C and Xcode.
For the moment I am using a table view and returning rows with cells containing an image thumb and title. My problem is that now i need to change the layout and for 4 of the cells I need to make them fall on the same row (so each article of the 4 should be 50% width). So basically create 2 columns but only for 4 of the articles. The rest remain on 1 column (full width).
I would add an image but I don't have enough rep points.
I know there is some thing like collection view...but I am not very familiar with that one and I was hoping maybe there's an easier way than redoing the viewcontroller and all the connections I already have created there.
Since I am already using tableview..what's the best way to change the layout to fit what I need now?
Based on what you're trying to do a UICollectionView might not be the best bet. I would create a second type of UITableViewCell for those rows with 4 columns. This should help Multiple Custom Rows UITableView?
You can use UICollectionView with flowlayout and variable cell width. There are many tutorials about it out there.
You can also try this library: https://github.com/bryceredd/RFQuiltLayout
Have you taken a look at this library:TSUIKit
If you just want to quickly arrange your data, this would be much easier than trying to wrangle with UICollectionView.

IOS table view inside of a table view

I have a table view with expanding cells for each of them. I want to make every expanding cell be a new table inside of the bigger one. Is that possible? I've done the research, someone said that duplicate UITableView cannot put in one file.
For example
dish order1
=================
dish order2
rice
coke
===============
dish order3
which every "dish order #" is a cell of a table, and when you expand one cell, there will be a smaller table appears. I've done all the expanding stuff. But don't know how to put a small table into a bigger one. Thanks
Well if i understand your question correctly, what you search is called nested tableView, here's some examples:
SDNestedTable
ExtensiveCell
CollapseClick
JKExpandTableView
Good luck.
It would likely be impossible to put one table view inside of another table view, and if you did manage to do it, it would be awful. Ask yourself, have you EVER seen this in a commercial app? If not, as a novice iOS developer, you are out of your depth trying to invent new UI paradigms.
Master the existing UI tools first. Don't try to use the UI elements in totally novel ways until you have a strong feel for the standard way to use them. Expect this to take 6 months or more.
Others have suggested a sectioned table view where initially only the first element of a section is visible, but when you tap on it, it expands to add other rows. This works quite well.
Another approach would be to use a master/detail UI, where tapping on one table view cell pushes a new view controller the uses a new table view to display detail information about the previously selected item. There are some use cases where you might have several levels of increasing detail.
I really do not think you want two instance of UITableView, instead what you want is a sectioned UITableView which expands when it's header is tapped. Apple has a good sample code for this here:
UITableView expand/collapse
i have demo for you , just got from github..
https://github.com/mitsBhadeshiya/ExpandingCell
i hope this is helpfull for you...
Have you considered using one UITableView with multiple sections? You can accomplish what you are depicting above with only one tableView.
Since this was a problem for many people in the past, iOS 9 has a thing called Stack View, it does exactly what you are saying.
Check out this article.

Moving cells from one table to another in iOS

I am trying to create an application with multiple table views that uses and implements Core Data. I would like the user to be able to select cells in one table and move them to another (like in Apple's mail application) using either a check accessory or a selectedCell method with an action sheet. I'm stuck because I don't know if you are actually moving the cell to another table or if you are adding a copy to the new table and deleting the original. Basically, I'm asking for a basic example of cell movement to give me a push in the right direction.
You won't be moving cells. The model for a table view is an array. Move things between the arrays and tell the tables that their model has changed.
id somePartOfMyModel = [self.arrayA objectAtIndex:someIndexPath.row];
[self.arrayA removeObject:somePartOfMyModel];
[self.arrayB addObject:somePartOfMyModel];
// the simplest, non-animated way to update the tables.
// I'd advise getting this working first, then later trying fancier UI to indicate changes
[self.tableViewA reloadData];
[self.tableViewB reloadData];
You would not be technically moving the cell to the other table. The way I would go about doing this would be to pass the NSManagedObjectContextID of the item between the tables, depending on how large your entities are and if the tables are in the same view controller.

Objective C: How to implement a datagrid view (tables with multiple columns)

I am currently working on an iPad application that uses a table view to present data, I was inspired by the iTunes application in iPad that present it's data in multiple columns in a very nice and neat manner, and the most interesting thing is that during the portrait mode the itunes application displays data in 2 columns but when the user switches to landscape mode, it switches the display to 3 columns (since there are plenty of space to display data horizontally).
This is what i'm talking about:
but i found out that iOS SDK only supports single column for tableview (it would be nice to utilize the entire space provided on iPad screen to present data), i did some research and i found out that the best way to present data in multiple columns yet like spreadsheet style is to use datagridview instead, but iOS SDK did not provide any data grid view controls for iOS developers.
I found out over the internet some customized tables like:
AQGridView.
DTGridView.
and also the one from this:
http://usxue.is-programmer.com/posts/14176.html
and the one from this:
http://xebee.xebia.in/2011/04/14/building-editable-gridview-for-iphone-apps/
But sadly none of these ever met the requirements of the application i was working on.
Could you guys provide me some ideas or share some sample codes or links on how to display data in somehow-data grid view, to achieve similar effect used in iTunes application (as shown above).. Any form of help would be pretty much appreciated. Thank you guys!
The summary answer is, place multiple data "views" across in a single cell.
The more detailed answer:
Create custom views that represent the single cells you want. You can for this purpose make them resizable enough to work two across or three across (they will get loaded into 1/2 or 1/3 of the cells bounds).
Then make a custom UITableView cell, that can take two or three data items - load up an instance of the custom view previously created in the cell for each data item you have, placing them next to each other. You can have the cell do the view layout when groups of data items are added.
In the cellForRow code in the table delegate/datasource, you use your data source in groups of two or three (and report the row count accordingly) to pass along to the custom cell.
Sorry I can't share code, but I have used this technique before in other applications.
What's wrong with creating a UIView class to represent a single cell, and another that lays out an array of those cells in a grid? Put your grid view in a UIScrollView and you're about done.
UITableView is obviously a pretty complex class. Much of that is to make it very general, very reusable, and able to support a huge number of rows. Your class doesn't necessarily need to be that complicated -- if you have a fairly small number of cells, your "grid" could really just be a UIView in which you lay out cells in rows and columns. UITableView removes cells that aren't seen in order to save memory; you might need to do something similar if you have hundreds of cells, especially if they're large, but a few dozen probably won't require that.
In short, since you need a grid view for a particular use, you don't need to do all the extra work that would be required for a general, reusable solution.

Resources