iPhone app - some custom UITableViewCell questions - iphone

At the moment, I have a settings view in my iPhone app built with Interface builder, it consists of a background image, some text fields, labels and buttons. Because this looks bad, I want to convert the settings view to an UITableView with custom UITableViewCells.
I already tried adding some cells into my settings view's XIB and returning them in the cellForRowAtIndexPath method (with [return myCell];), as written in Apple's tutorial, but this was not working for me - my whole TableView looked strange and it only showed the first cell correctly.
Is it possible to design these custom cells in Interface Builder? Do I have to create an empty XIB for them or can I put them in my view's XIB? And how do I insert them into my TableView?
Thanks in advance,
Yassin

You can absolutely add custom table cells that you built in interface builder. This includes both static cells and Dynamic cells. However without you providing more information the best I can say is "double check the docs and try again." I can only say that it works and it's rather straightforward so it's hard to say what you may have missed. It might be more helpful if you post what you have for the tableView:cellForRowAtIndexPath method.
Since you say you just have some text fields, I would recommend looking at the technique for static row content section of the Table View Programming guide. You probably would want to have each field of your form correspond to a row in a Segmented Table View, it'll make everything look nicer.

Related

UITableView Margined/In Header

I'm looking to create the TableView section contained in the header of this tableview (the "margined" area with Eric Mulder typed in). Does anybody have any insight on this matter? Thanks!
You can't do it easily with a delegate method of UITableView. I got it to work by creating an image which contains a the style of the default cells of a table view. Then I simply load it as an UIImageView in my header view of the table view.
For example, you can take a look at my app iCookit (App Store). You can see the work on the 3rd picture. That's the result. It was very easy to do. Just a little bit with Photoshop or Gimp.
Have you tried setting a UIView that contains both the photo well and a UITableView for the name fields as the main UITableView's headerView?

table view cells with different controls

I was working with the grouped table view , and i wanted different controls for every row i.e switch control for 1st,radio button for 2nd ,checkbox for 3rd and so on.. how can this be implemented programmatically that is without using interface builder
thanks in advance
CharlieMezak said is right, you need to create in UIControls directly in cellForRowAtIndexPath , and add as subviews to contentView of the cell
For reference see the link below
http://www.e-string.com/content/custom-uitableviewcells-interface-builder
the link specifies the code to create cells programmatically as well as using IB.
Table View Programming Guide for iOS
Read the programing guide, and remember to use different CellIdentifier for each type of cell.
This is a pretty vague question.
Obviously you need to provide the cells to the tableview in its cellForRowAtIndexPath delegate/datasource method. So, either in that method or during the initialization of your view controller, build the UITableViewCell instances that you need, adding the various controls that you want to them as subviews and connecting the controls to your view controller so you can detect when they have been changed. Then just return the appropriate cell in the cellForRowAtIndexPath method.
Personally, I think it's a lot easier to use IB in cases like this. Just create an IBOutlet instance variable for each custom cell you want, and return the right cell in cellForRowAtIndexPath.

Left area of section in iPhone TableView

I have a section where I would like to customize the left area of a section a TableView - a bit like viewForHeaderInSection.
I have thought at using a cell for the section instead, but it would be a lot of nitty-gritty.
If I understand your question correctly, you want to customise the left-hand-side of some, or every cell in a UITableView? Then you need to make create your own custom table view cells. I normally make these cells in Interface Builder; this post helped me out. See also the Customizing Cells section of Apple's Table View Programming Guide for iOS.
I read your question to mean that there is one custom element to the left of a bunch of cells. The only way I know of offhand is to use a cell as you describe and then have a left view and a tableview inside of it.

iPhone Recent Calls Details View - Custom Cell?

I would like to have something that would kind of replicate the details view of the recent calls tab on the iPhone phone.app.
When viewing the recent calls, tapping the disclosure button takes me to the view pictured here: http://img337.imageshack.us/img337/3456/recentcalls.jpg
I would like to know if that area in blue represents a custom cell. Am I right? Or is there an easier way to accomplish this?
My need for replicating this comes from my trouble with heightForRowAtIndexPath, as explained here: heightForRowAtIndexPath for only one section?
(I won't be using heightForRowAtIndexPath anymore with this solution).
Thanks in advance.
It looks like the area you've outlined in blue is the section header for the first section. You could also just use the table header.
Matt Gallagher posted a nice article on customizing your table header.
If I had to guess, it is likely a custom section header view, glued together from various labels and other widgets.
It would certainly seem much, much easier IMO to do this with a custom table view header view than with a custom table view cell.
See the table view delegate method -tableView:viewForHeaderInSection: where you return your custom UIView object for a given section.

Multiple images per row in UITableView's cell

Is there any sample code that would illustrate how to have multiple images within each row?
Typical apps show a thumbnail to the left side with text to the right. I'd like to do that plus an image to the right of the text.
How would I go about doing this?
In interface builder, simply create a tableview cell that looks like you want. Then create a UITableViewCell subclass that has properties pointing to the elements of the new cell. Set the class of cell to the subclass then add cells of that class to the table in the standard way.
A tableview cell is just a view and you modify it and use it just like any other view.
You'll have to create a custom UITableView cell. Here's an example of using multiple UILabels in one. Here's another.
Pretty easy - follow Apple's documentation to create exactly the cell you want in Interface Builder with as many UIImage or whatever else you like. Look at Table View Programming Guide for details on how to make and load the custom cells - just be careful about performance when you put a lot of visual elements in a table view.