Insert cells into a section of an already statically created table - ios

I am creating an iOS app that has a form to create a certain 'event'. This form is wrapped in a tableview. This tableview consists of static cells. But there is one section in the table that can be used to add persons to this event and thus on a button press a new tableview cell needs to be inserted at that section. To demonstrate this see the following image:
What I want to know is how to insert cells into a static table. And also how to grab them when the user submits the form, since, as far as I'm concerned, you can't grab a specific section of a table.
I already looked at this kind of concept but this does not apply on adding cells:
Mixing static and dynamic sections in a grouped table view
Thanks,

I think there are (at least) 2 workarounds for this:
You could add a dynamic UITableView as a child to the UITableViewCell. See this stack overflow question about this.
An other solution would be to bypass the table functionality in that cell and change the height of the cell and add the extra controls manually.

It's not possible to add or remove cells at runtime, you'll need to use a data source for your tableview. I asked a similar question here, with no luck.
In response to your second question, you can always grab cells using the cellForRowAtIndexPath: method on UITableView.

Related

save data in array coming from 2 different uitableviews in ios swift

Recently i am facing an issue in saving data of Uitableview inside Uitableview cell in ios swift
Senario
Questions asked in above pictures is one table view and this table view cell contain 1 label for question text and uitableview that show possible answers provided by admin and user is allowed to select one.i am enable to display data perfectly but facing an issue when trying to save answers of every question in one array.it always store the value of last questions answers.
Why are you using two different UITableView? Any specific reason? You can get data from different resources but there is no need to use two table views.
You should use a section header view to show the questions & sections rows as options(answer option).
You can dynamically add or delete the options(rows) from any section(question). Also, there will not be the above scenario if you implement it using this easy approach.
Let me know in case of any query.

Static table cells with detail

I'm trying to make an iOS 'information' or 'guide' app in Swift. I wanted to utilise the Master Detail template so that when the user clicks a cell it will take them to a relevant ViewController with either basic text labels or a PDF file.
From what I understand, Dynamic Cells can be dynamically changed whilst the app runs however I want to set static cells from the storyboard (or programmatically) and their relevant content/PDF files so the user can view each one. I don't want any "new cell" or "editing" functionality.
How can I make this work? I would post my code so far but it's almost identical to the Master Detail template so I don't see any use. I know this is quite a vague question but I need help and don't know where to start.
Any help will be so appreciated!
A static table cell can entirely be created via storyboard. In the storyboard once you add a tableviewcpntroller you can prototype call added to it.You can add as many prototype cells to your table ( not necessarily every one should have common layout). After all cells are added you can assign individual tags to the cells if you need identify these cells from your code.You can add segue from each cells to move to different page.
Let me know if something more is needed.
In Interface Builder set the Content of the table view to Static Cells.
Drag as many table view cells as you need into the table view.
In the controller create IBOutlets for the labels and the other UI elements.
Connect the outlets in Interface Builder.
Rather than using the datasource methods assign the values directly to the UI elements via the outlets.

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

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

How can I build an UITableView like App Store? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I whant do build an table view like App Store.
eg:
As we can see, App Store app enables the user to drag the rows down and the header keeps on top...
and ... when you slide up the rows, table's the header moves out the screen...
and its possible to slide the heander like so...
Here ive create an projec that aims to accomplish that.
source
If someone can help me I appreciate it.
Thanks a lot!
*
You aren't clear about what behavior you are looking for. Do you want the header to stay or not? You have also not shown any code, so we don't know anything about your table
here's some things found by simple search:
link
That behavior is only common when the UITableViewStyle property of the table is set to UITableViewStylePlain. If you have it set to UITableViewStyleGrouped, the headers will scroll up with the cells.
link
Actually the tableHeaderView scrolls with table. This is not the case for section header views. If you have only one section then you can have the header view as tableHeaderView.
table.tableHeaderView = aUiView;
If you have more than one sections and all of them have their own header views, then you have no choice than leaving the header views behave in their own ways. Or, you can imitate the header view by making/configuring/customizing the first row of each section look like header view and remove the actual section header views.
link
I think the best approach would be to use a plain UITableView with Header and Footer set, and "skin"/theme your custom UITableViewCells to look like grouped UITableViewCells.
you'd might want to have a look over here for some pointers on how to achieve this.
*
The cells you are referencing are table and section headers
You can include a custom header for every table section by implementing the UITableViewDelegate method
tableView:viewForHeaderInSection:
There are equivalent properties and methods for the table and section footers. (this is a good reference)
Create custom UIViews to assign to the headers and footers.
For the Horizontal scrolling behavior, you should place a TableView in the header/footer and rotate the table by 90 degrees; then in the cell of the rotated table, apply the rotation in reverse to the actual content. Now you have a cell that displays horizontally scrolling images etc.
In the code for the header/footer, create a TableView and transform the table
self.horizontalTableView.transform = CGAffineTransformMakeRotation(-M_PI * 0.5);
Then, in the cells of this table, you apply the transform in reverse on the content of the cell.
CGAffineTransformMakeRotation(M_PI * 0.5)
Voila, Horizontal Scrolling (see this tutorial:http://www.raywenderlich.com/4723/how-to-make-an-interface-with-horizontal-tables-like-the-pulse-news-app-part-2)
You are referring to UITableView as well as UITableViewDataSource and UITableViewDelegate classes. (easier than it sounds) They work together to create dynamic table views.
UITableViewDelegate
Serving as a table's delegate means you provide answers to requests about the layout of the table and about actions the user performs on the tableView. Layout methods include the tableView asking about the height of rows, headers, and footers, what the buttons should look like, etc. Action methods include the user selecting a row and beginning and ending the editing of a row.
UITableViewDatasource
Serving as a table's "datasource" means you provide data for the sections and rows of a table and you act on messages that change a table's data. The "datasource" is asked for the data for a cell when the table is drawn, is told that the user has asked to delete a row, and is told the new value of a row that the user has edited.
There is a great tutorial on tableviews treehouse.com seen "Here".
Don't take the title literally just choose piece by piece the lines of code you can imagine using for your application! It even covers the feature you outlined in which the alphabetical header is displayed while scrolling using the tableViewDatasource and tableViewDelegate classes.
Also there are probably great repositories on "github" (didn't they just receive 100 million dollar funding?) Try finding or 'hacking' some of there code to make it easier.
Nice images BTW. Very high quality

Toggle showing/hiding child table cells iOS

I'm trying to create a UITableview that contains STATES and CITIES. To start with, I'd like the table to display only the STATES, with each value having a downward facing disclosure arrow on the right hand side of the cell which lets the user know it has values underneath it. If the user clicks the arrow, the table would expand to show the CITIES associated with the selected STATE. The user could then either select a CITY, or click on a upward facing disclosure arrow which would then "hide" the CITIES.
I've downloaded and reviewed Apples "Table View Animations and Gestures" example.
I was hoping someone might know a simpler way of accomplishing what I'm asking for.
http://developer.apple.com/library/ios/#samplecode/TableViewUpdates/Introduction/Intro.html
Good Job on explaining exactly what you want to do. This is how I would tackle this, I figure it would be easier to explain it without giving you meaningless code and answer any coding concerns you might have after.
I would set up the table view data source to be an array of arrays. The idea would be that every index in the array would represent a state and therefore contain a number of cities, hence ever index contains an array (array of cities). The parent array(of states) will be empty at the beginning, but the arrays(of cities) that will later fill it would be populated with the appropriate cities.
I would then set up the table view to contain sections (I a tempted to put code here, but read along). The sections would represent the cities. You can then fill out the table view with sections using (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section delegate. On the first run you can fill the actual table with one cell per section (maybe with the word "expand" or "more" and your down arrow). When the user touches that cell you can use the didselectrowatindexpath to know which section was touched (the indexpath object contains the section), now that you know which section it is, just modify the data source by adding the array of cities for that section of the array of arrays (parent array) and update the tableview.
This essentially gives your tableview an according style and feel. It is very easy to implement but requires a little bit of code. I have done this and am willing to provide the code you might need, the trickiest part would be to update the tableview in the correct way.
EDIT CODE:
I did a simple example following above explanation. The code is on Github , feel free to ask any questions about it.
I think a better way to represent this information would be to have a UITableView containing the states with each state showing a tiny arrow pointing to the right. Then, when a user clicks on the state, load the next UITableView that shows all of the cities in that particular state. Using a UIViewController for pushing the City list will allow users to easily return to the States list.
This approach will make much more sense to iOS Users, because this is how they expect Tables to work.
There are many tutorials explaining how to use UITableView. Here is a link to a site with many UITableView tutorials. The tutorial I linked to explains pushing a UIViewController on to the stack so that there is a simple back button back to the State list.
Normally such thing is done by seguing to another view and showing more details about cell.
What you want you could achieve by actually making custom UITableViewCell which would contain UIButton with arrow image and UITableView. In case button is clicked for the first time you could reload your cell and create inner UITableView which could show cities. Another click would simply reload cell again and not return inner UITableView at all. You also need to keep selected state somewhere because you may have to reload previous cell and hide inner table in case arrow in other cell is clicked.

Resources