Re: UITableCellView width decreases when scrolling
Re: UITableCellView width decreases when scrolling
- Subject: Re: UITableCellView width decreases when scrolling
- From: Koen van der Drift <email@hidden>
- Date: Tue, 16 Apr 2013 14:25:25 -0400
On Apr 15, 2013, at 7:20 AM, Koen van der Drift <email@hidden> wrote:
> The reason I was using drawRect is that my cell contains some text, plus a small graph (a few changing lines, so I cannot use an static image) at the bottom. Therefore I was using CoreGraphics, and I decided then to also draw the strings that way.
>
> Even if I use labels for the strings (which I agree is much easier and customizable), then I still would need a subview for the bottom half of my contentView to draw in the graph. Unless there is another solution?
I'm having some troubles with the custom view to draw my graph in.
I created a xib for my cell with a bunch of labels and a UIView, as well as a UIView subclass (MyCustomView), where in the drawRect method I draw the graph. The UIView in the xib is set to the Class MYCustomView.
In the UITableViewController I added the following to set up the cell:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCustomCell *cell = [tableView dequeueReusableCellWithIdentifier: @"MyCell"];
if (!cell)
{
cell = [[MyCustomCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: @"MyCell"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
MyObject *o = [self.myArray objectAtIndex: [indexPath row]];
cell.labelOne.text = o.name;
cell.labelTwo.text = o.info;
cell.myCustomView.object = o;
return cell;
}
And then in drawRect of MyCustomView I extract the info from the object to setup the draw parameters and draw my graph.
Now the first few cells are drawn ok, but after that, I see the graph based on the info from an object that has already been drawn. If I put in an NSLog in drawRect, I indeed see that this is called only a few times, and after that not anymore. But labelOne and labelTwo are fine for all cells and called all the time.
Why is drawRect only called for the first couple of cells, and after that not anymore?
Thanks,
- Koen.
_______________________________________________
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