• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with UITableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with UITableView


  • Subject: Re: Problem with UITableView
  • From: Dave Carrigan <email@hidden>
  • Date: Sun, 1 Aug 2010 22:38:43 -0700

The typical idiom is to try to dequeue a reusable cell. If that returns nil, create a new cell. No matter whether it was dequeued or created, configure the cell (i.e., assign values to labels, configure decorations, etc.). Dequeuing saves you the overhead of creating new views but you still need to completely configure every cell that you return from -cellForRowAtIndex:. If you're dequeuing properly, you should expect to have 1 cell object in existence for every row in the table (and probably more, depending on how aggressive the OS is about re-using cells).

Dave Carrigan
Seattle, WA

On Jul 31, 2010, at 10:25 PM, Laurent Daudelin <email@hidden> wrote:

> Isn't the purpose of dequeueReusableCellWithIdentifier: of reusing tableview's objects? I've used this in the past and it never failed me. The documentation says "For performance reasons, a table view'€™s data source should generally reuse UITableViewCell objects when it assigns cells to rows in its tableView:cellForRowAtIndexPath: method". So, that's what I'm using. Of course, I have 2 different cells for the 2 sections and I can't understand why it doesn't work. Right now, I have 4 cells in section 2 but in the future, I might have dozens of cells representing dozens of entries. I cannot possibly create a different cell for each row, can I?
>
> -Laurent.
> --
> Laurent Daudelin
> AIM/iChat/Skype:LaurentDaudelin 				http://www.nemesys-soft.com/
> Logiciels Nemesys Software              			email@hidden
>
> On Jul 31, 2010, at 22:20, Luke Hiesterman wrote:
>
>> Are you returning the same cell 4 times? That's not right. You're going to need 4 separate cell instances even if they are of the same class and layout. It sounds like you might be taking 1 cell instance out of a nib and returning that each time.
>>
>> Luke
>>
>> Sent from my iPhone.
>>
>> On Jul 31, 2010, at 9:17 PM, Laurent Daudelin <email@hidden> wrote:
>>
>>> I've been banging my head on this for over a day now and I just can't find what's wrong with my tableview and the tableview cells.
>>>
>>> Basically, as you can see here:
>>>
>>> http://nemesys.dyndns.biz/Images/iPhoneScreenshot.png
>>>
>>> I have a table view made of 2 sections. Section 1 has only one tableview cell and, right now, it's barebone. Section 2 is supposed to have 4 cells. When I use a cell from my xib file in Interface Builder and the tableview appears, even though my method tableView:cellForRowAtIndexPath: is called 4 times, only the last cell is showing. If I however create the cells programmatically using:
>>>
>>> [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]
>>>
>>> then they show up properly. Of course, the cell is created only once because on subsequent calls, I'm using the tableview dequeueReusableCellWithIdentifier:.
>>>
>>> I just don't get it. I use the same methods to set the textLabel and the detailTextLabel in both cases. I just tried a few times of dragging a default UITableView cell from the IB's Data Views tab, I don't modify it in any way in IB except to give it a cell identifier and connect it to my tableview controller so it can provide it to its tableview, it just won't work and I get the tableview showing as in the picture above. I want to use a tableview cell in IB because I need to add additional labels to it and don't feel like doing it programmatically.
>>>
>>> So, anybody can see what I am missing? I've done the same thing in other iPhone projects I just can't see why I can't do it now and I'm at the end of my rope here.
>>>
>>> Thanks in advance for any comment, info or help!
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Prev by Date: Displaying an edit field in a cell at the bottom of the tableview (2)
  • Next by Date: Re: 3d cube using public api of CoreAnimation
  • Previous by thread: Re: Displaying an edit field in a cell at the bottom of the tableview (2)
  • Next by thread: Re: 3d cube using public api of CoreAnimation
  • Index(es):
    • Date
    • Thread