iOS Get Values of Controls in UITableViewCells - ios5

So, I'm a bit of a noob to iOS (PHP dev). I have a UITableView in a UIViewController. The cells consist of a combination of any of three different custom prototype cells. Which cells are loaded is based on a service that loads the questions and types. One has a segmented control with 2 choices, another with 8 choices and the third has a UITextView to receive a comment. This is essentially a survey. I can grab the values of the controls as they are answered, but I'd like to be able to just gather them up when the 'submitResponses()' method is called as an action attached to the 'Submit' button.
Any ideas? Should I be going about this in another way?

The "correct" way to do this is definitely to collect the data as it is entered!
One of the biggest problems with the approach that you suggest is that for larger tables it simply won't work because if a table view cell is off the screen, you can't access it or the controls/views that it contains (and it may not even exist yet!).

Related

swift - tableviews, a point in the right direction

i am working on an app that lets the user enter some information which then gets loaded online. As part of my project, i want the user to enter some information and it would be alot easier for them if there was a table allowing them to enter it , ok so the problem is, I have a view controller with a scrollview which gives me some more space i can work with.
I want a way where i can display a table 5 columns across and the rows will depend upon the user, the table should only take a small amount of space on the scrollview, the table will allow information to be entered into the cell which later will be saved. i just need a point in the right direction on how to go about this problem. I am fairly new to swift and any guidance would be much appreciated, thanks in advance
Based on your requirement of having both columns and rows—I would look into creating a UICollectionView and populating the cells with UITextFields.
Please learn about UITableviewController here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewController_Class/
There are no columns, just rows, and you don't need an extra scrollview to contain your tableview in. There are plenty of tutorials out there that teach how to work with table view controllers. You should seek guidance here if you have a particular problem with implementing them.

Load different views depending on the category of data on tap of tableview cell iPhone sdk

In my aplication, I want a tableview with different cell structure depending upon the category of data that's getting loaded in it [I have different categories like video, editorial etc with different structure of data like video has a single label, editorial has 3 labels etc]. I can load different nib files based on the data coming from xml parser.
Now when the cell is tapped, I want to show its detailed view on a new viewController. So my question is is it possible to use only 1 viewController show different fields depending upon the category of data in the cell. Or do I need to create different viewControllers for each of the categories?
You can use single view controller. Only thing is you need to feed the data to be displayed in that view controller.
But keeping separate controllers for different functionality will make your code pretty neat and easy to handle. So It would be better if you keep separate controller for handling the data.
You can write code to do whatever you like. But using the same object to display multiple object types wouldn't be considered good practice, assuming that the elements you will be displaying are different.
In OOP, we normally create different classes to simplify code, and share code using various strategies, of which subclassing is would seem appropriate to this case.
Meaning: create a class to handle the general cases applicable to all the object types you want to display, and subclass for the specific requirements for each type.
It depends on what kind of data you have in each of your categories. If the format of the data in each categories is different and you already know it, design viewControllers such that they directly read the data and display it however necessary. The viewController should itself handle the displaying logic.
On the other hand, if all categories are of the same type, you can create multiple instances of the same viewController, use them and release them as necessary.
In your case, it sounds like the second option can be preferred.
Edit: It would be wise to go with different sub-classes of viewControllers keeping design pattern in mind - "Closed for modification and open for extension".

ipBest Practice IPhone Interface Design

I'm trying to figure out the best way to display a long list of controls that go off screen? If you have played or seen IMobsters, it's kind of like the missions tab. There are 15 jobs, each job "section" would have 4 labels, 2 buttons, and an image. I want some static info at the top, then be able to scroll through all the jobs.
Also, do you ever run into a "Feasibility" limit for how many controls you have to code and connect using IB? There would over 200 different labels and controls here I would have to make IVARS etc. Is there a better way?
I'd suggest using UITableView for your purpose. Each cell will correspond to job 'section' you described and will contain 4 labels, 2 buttons, and an image (or whateve you want). UITableView will handle scrolling your contents if it is too large, proper reusing of its cells will also allow you to avoid creating >200 instances of UI elements and will improve your app performance and memory usage.

How to implement a large grid of cells in an iPhone application?

In reference to my previous question, I would like to know how to implement a large grid of cells in an iPhone application.
I'm working on an interface which would be similar to an Excel spreadsheet, with many rows and columns. Do I have to handle each cell separately? How can I handle user interaction in each cell?
Is there a standard way to create this type of control?
There is no real standard mechanism.
If all of the cells in a given row will always fit in the width of the screen, one way to do it would be to create a UITableViewCell with several UILabels and vertical separators between them. If all of these rows had "columns" of the same width, you would get the appearance of a grid.
If that isn't possible, it might be helpful to think about what the table view control truly is. A table view is just a scroll view that automatically adds, removes, and recycles its subviews so that only the ones that are visible at a given time are in memory. There is no reason you could not write a GridView control that did the same thing, but in two dimensions. It wouldn't be as easy as using the built-in table view, of course, but if the table view can't do what you need, well, that's why Apple isn't writing all the apps.
Sounds like the exact thing that UICollectionView was made for!
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UICollectionView_class/Reference/Reference.html
Look at my answer to this question: MS Excel type spreadsheet creation using objective-c for iOS app.
Basically there's no standard way to do this. You will need to made everything by hand and there's 3 ways to go:
Use a UIWebView and layout everything using html/js.
Modify a UICollectionView.
Make everything by hand using Core Data.

Generate View for iPhone application using interface builder.?

I wanted to generate one fix view using interface builder, but the size of that view is exceeding the size of iphone screen,and I am not able to maximize screen. I wanted to show table view in that screen.
I did enabled scrolling but that didn't work,
Update 1:
Actually I wanted to show thumbnail image inside cell and i want to show 5 cell so 5 thumbnail image,those images are static. So which is a better way to achieve this ,interface builder or programming?
Hope this is clear enough.
Your question is not terribly clear, so this is the question that I am attempting to answer here:
You want to have a table view which has five rows, each of which has a small image.
Short answer: you can't do this entirely in the Interface Builder. What you can do is define your table view, including the "look," scrolling abilities, etc. And then in the same XIB file you would define the table cells (which can include your pictures, captions and what have you).
You then have to connect the two together programatically. Apple provide plenty of examples in the SDK on how to do this.