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.
Related
I need to display a simple list where each cell has a title and subtitle and an accessory view. Height of a cell may be variable depending on subtitle length. This was easy to display using UITableView. But I saw a more modern way is to display such a list is UICollectionView with list configuration. There are a number of videos on list configuration & diffable data source and number of tutorials as well on the same but what I am trying to understand is if Apple is telling developers to move to UICollectionView from UITableView (which some experts surmise is going to be deprecated given the new APIs). So my question is whether one should abandon UITableView to display such a list mentioned above, and if UICollectionView is really a replacement for UITableView?
Apple started killing UITableViews years ago, likely 5 or so. They're still here and still going strong. UITableViews will still work and there's absolutely no reason for you to drop them and replace them with UICollectionViews.
I'm looking to make a questionnaire app and trying to figure out the best way to implement this.
I'm familiar with TableViews and how to load content into them from an array but I'm having trouble figuring out a way to create a dynamic TableView that can expand or shrink depending on how many questions are asked per view.
My questions will be grouped so that each "page" will only display 1 group of question or questions at a time. This can vary from 1 question or more.
Every question will have 3 attributes of:
questionNumber, questionLabel, and questionType. These are all strings.
There are 7 question types which are:
yesNo, date, time, search, multipleSelection, textField and prompt.
Do I need to create custom cells for each and load them into the TableView or could I make separate Views that would then be loaded into a TableView?
I'm also going to use either a toolbar or a navbar to for the user to tap which would be next to go to the next group of questions or tap on previous which would get them back to the previous group of questions.
Any help to point me in the right direction would be appreciated. As of right now I would need to make 15 different view controllers and looking to possibly reduce the amount by just creating a TableView that would expand and shrink with questions and questionType. One page might only show a yes or no question while another page might have 2 or more questions each with a different questionType attached to them.
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.
I´m struggling a lot to find a good solution, and searched a lot also, but i can´t find anything similar with what i want, so i hope anyone can help me:
I have two tableviews, in the first one i already have custom cells, and each cell has two textfields, one textfield for the product name, and the other one to it´s price, then if the user want´s, he can had more cells which he will insert more products with their respective price.
The second tableview has also two textfields, in the first textfield he will choose one product( inserted in the first tableview)with a pickerview, and when he chooses the product, i want the respective price to appear in the other texfield.
My question is, should i be using core data? or another type of persistence? and is it possible to assign the values of the texfields to the atributes created in a model of core data?
You can use core data for your requirement and you can assign the data to textfields.
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.