On 23 Aug 2009, at 7:19 PM, Chris Idou wrote:

I'm trying to make a custom UITableViewCell, but the way I'm doing it, all the drawing of the table seems to be screwed up. The view seems to be working in some sense, because I can see the data, but only one row at the bottom can be seen and things are generally screwed up when scrolling. This is what I'm doing:

1) Create new Navigation based app.
2) Add a Table View Cell to the RootViewController.xib
3) Edit the TableViewCell in IB, add some Labels onto it.
4) Connect TableViewCell and Labels to outlets in RootViewController.h
5) modify tableView:cellForRowAtIndexPath: so that it sets data in the UILabels and returns the TableViewCell from the Nib outlet.

Is there some reason this shouldn't work?

I'm sure this is somewhere in Apple's sample code, or in the relevant programmer's guide, but I don't have time to look it up.

If you're laying out a cell in Interface Builder, the cell has to be in its own NIB. This is because each cell (on display) in the table needs a separate instance of UITableViewCell.

You have to have onw outlet for a cell in your table-view controller, use the controller as File's Owner, and link the cell to the outlet. In tableViewCell:forRowAtIndexPath: (note lower-case F), if a new cell is needed, load the NIB. Take the cell from the outlet, retain +autorelease it, and nil-out the outlet.

You may have to implement tableView:heightForRowAtIndexPath:.

        — F

--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/ >

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to