xcode : how should we display large number of Label & buttons in Tabular form? - iphone

Actually I am having problem in displaying around 10-15 rows of Label & Button controls in view. Then I used UIScroll view to achieve this but that corrupt the appearance of design.
As you can see the generated output is different from the appearance in the Xcode while developing.
Please guid me what should be done to render proper design?
Thanks
Ashish

You should use UITableView.
Create custom UITableViewCell.
Your each row will contain one UILabel and UIButton.
You can check.
See the attached image :

Create a custom UITableViewCell and use that one in your code.
And in cellForRowAtIndexPath assign values to your cell properties.
Refer this Apple sample code
Also there are so many examples over net, search for custom UITableViewCell and you will find various tutorials out there.
Here is one more third-party tutorial link:
Hope this helps.

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?

TableViewCell in IB or Programmatically, which one is better for customization?

I'm coding a custom TableViewCell and I need to set a background image for each one (actually same background image on all cells) and I'll add some labels for different type of texts (different in font, size, color, etc...) and a left image hosted on a web server. I've read a tutorial on how to make the TableViewCell using IB and add it to cellForRowAtIndePath method. It worked but the image size and texts in labels are not showing like I was seeing them in IB, not wysiwyg at all lol
So, I need your help to choose the proper way to customize these cells, should I go for the IB way or programming tips are better?
Thx in advance for helping,
Stephane
I am guessing that the size of your images is going beyond the expected size of the imageView property for the left image. That usually pushes around all the other UI elements. You can avoid that by setting imageView.layer.masksToBounds of your cell to YES.
In general, for the problem you describe, I would recommend doing everything programmatically. You will have the opportunity for abstraction and include your program logic more economically.
To keep your cellForRowAtIndexPath method reasonably short, you can call your own formatCellAtIndexPath method and keep the formatting logic neatly separated from the content.
I find it easiest to create the TableViewCell in IB to start with and then, when I have it looking the way I like it, to switch to a cell built programatically.

Mimic ABNewPersonViewController UI

I'd like to replicate the iOS 4.x ABNewPersonViewController UI layout (see link text) in a custom view but I'm unsure about the best way to achieve this. I was thinking of a single grouped UITableView, but what about the first section? How do I achieve the smaller cells (first,last,company)? And finally the "add photo canvas" is it just a sub UIView with a background image for the shadow and the rounded border or can this be done programmatically?
Many thanks in advance!
your idea about a single grouped UITableView could work. The way to get the smaller cells as well as the photo cell would be to subclass UITableViewCell and create it like that. and yes the photo canvus is just a custom UIView added on top of the UITableView. I'm not sure i see the point of rolling your own here, but thats how i'd start. Also i think i recall seeing a tutorial on how to build this page..try googling for it.

iPhone app - some custom UITableViewCell questions

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.

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.