Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ajayrsawant

macrumors newbie
Original poster
Oct 6, 2009
5
0
Guys,

I am new to IPhone, can you please help me with following approach.

I have an requirement of having multiple text boxes into the UITableCellView, they need to placed vertically so I am thinking of using UITableView inside above cell.. so I can simply push the text box and label controls into this UITableView. So I don't have to place them manually.

Can someone please help me with this.

Thanks
Ajay Sawant
 
We all were new at some point ;), but before you ask a question, its very important we get the terminology right. I'm not quite sure what your asking,
I have an requirement of having multiple text boxes into the UITableCellView, they need to placed vertically... so I am thinking of using UITableView inside above cell..
You want a UITableView inside above cell, your effectively saying that You want one MORE table inside a single row of the big table. I'm pretty sure you dont mean nor you require nor you'll be accepted with this layout in apple.

One Cell is a single ROW in a table.
Do you want ONE textBox in One row?
Or you want Multiple textboxes in single row?

want you need is what we call a Custom made UITableViewCell, thats a single cell. Take a look at UIControls example at apple site.
In a single word, you need to subclass tableViewCell, add textbox to it.

i could tell you more if you can be a lil clearer..
 
Thanks a lot for your reply mraheel

I know the requirement I have is odd but I need to show table cell in following way

---------------------------------------------
<UILabel> <UIRadioButton> <UILabel>
<UILabel> <UIRadioButton> <UILabel>
<UILabel> <UIRadioButton> <UILabel>
---------------------------------------------
<UILabel> <UITextBox> <UILabel>
<UILabel> <UITextBox> <UILabel>
<UITextBox - Multiline>
----------------------------------------------
<UILabel> <UICheckBox> <UILabel>
<UILabel> <UICheckBox> <UILabel>
<UILabel> <UICheckBox> <UILabel>
<UILabel> <UICheckBox> <UILabel>
<UITextBox - Multiline>
----------------------------------------------

In above I am trying to show three rows and each row can have N number of lines/rows holding set of different controls

I am aware about the fact that we don't have anything called UICheckBox or UIRadioButton for IPhone but I need to tweak UIBUtton control to do so.

The reason having UITableView in Table Row is to display above control sets in nested UITableView so I don't have manually manage the control placing like X and Y and even the height for main rows.

Let me know if I am heading towards wrong direction.

Thanks Again
Ajay Sawant
 
The requirement is indeed ODD!

The reason having UITableView in Table Row is to display above control sets in nested UITableView so I don't have manually manage the control placing like X and Y and even the height for main rows.

Okay, so you keep adding new cells to your table within a tablecell. and not be bothered about much!, ok,

Are those 3 rows fixed, by that I mean only 3 or can be more?

If more, we are effectively talking about more number of tables with each row??

If however, the 3 rows are static and fixed,
-You clearly dislike scrolling the whole view. Cuz that will be lost.
-you dont need a Main tableView, you can house (probably, but i never tried it) 3 tables on 1 UIView with manual sizes each having their own custom cells.

In either case, that means, One view with Multiple tableviews, which means, multiple IBOUTLET connections, which means multiple datasource, delegate protocols for each of them. All this depends on the purpose and requirement ofcourse, I dont know your purpose so I cant rule it out,

The reason having UITableView in Table Row is to display above control sets in nested UITableView so I don't have manually manage the control placing like X and Y and even the height for main rows.

This reason, Amm, I dont know, your sacrificing alot for "not wana manage control placing" which is not a big deal actually..
i suggest you first exhaust other approaches before attempting this,
How about placing a segment control on NavBar with 3 Views each having a tableView.?


The Purpose and the 3 Rows( Being static or not) will define your direction
 
Few suggestions:

Consider using a grouped table for this. Each of what you show as a row could instead be a section in a grouped table. Then each of the lines that you show with controls could be a row. You can turn off the separator lines between rows if you want.

If you only have three sections/rows as you show, laying these out in IB would probably be simpler than code.

Look at Settings.app and see if there is anything in there that has a design similar to what you want. That will help you to think about this design.
 
Thanks a lot for your suggestions guys.

Using grouped UITableView looks promising to me because rows are not fixed.

Can you guys also help me to understand that when I use grouped UITableView and placed my input controls into the rows then I will have save button in table footer but on the click of this button how can I loop through the controls residing into the table rows to validate and capture the inputs ?

Thanks again for all your help, I really appreciate.

Ajay Sawant
 
You should consider validating and capturing inputs individually as they've been changed (when they resign first responder status) unless you have a strong reason for delaying this until later.
 
I actually have UITableView with many text box into it and once user is done with all the data entry he will hit save button at bottom.

This is the time when I would like to get the values from all the text boxes residing into the cells of UITableView.

Thanks
Ajay Sawant
 
Guys,

I got one more problem, can you please help me with the same.

I have UITableView which has two cells, first cell has switch control and second cell has text field. how can I get those controls in my controller class?

The reason I need those controls is that I would like to set on and off state of switch control and also need to do some text validations on text field control.

Thanks for your help
Ajay Sawant
 
How are you adding these controls to your UITableViewCells?

There are a number of ways to achieve what you want but the accepted approach is to use the Model-view-controller pattern. With this you would have a model that contains the boolean and string that equate with your UISwitch and UITextField. Your viewController (i.e. UITableViewController) then interfaces with your model through its APIs to retrieve, verify and set the values of these properties within your model instance. Also, it will be responsible for updating the view (e.g. [tableview reloadData]) to reflect the values of these properties within the UI (i.e. update the UISwitch condition and UITextField text). That's a fairly high-level, simplified explanation but should get you started.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.