setFrame: weirdness in UITableViewCell
setFrame: weirdness in UITableViewCell
- Subject: setFrame: weirdness in UITableViewCell
- From: Laurent Daudelin <email@hidden>
- Date: Wed, 08 May 2013 15:30:06 -0400
I'm trying to use a custom view which does only one thing: drawing the rect defined by its bounds:
- (void)drawRect:(CGRect)rect
{
// Drawing code
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
byRoundingCorners:UIRectCornerAllCorners
cornerRadii:CGSizeMake(4.0f, 4.0f)];
[path setLineWidth:2.0f];
[[UIColor darkGrayColor] set];
[path stroke];
}
I have one instance added to a UITableViewCell in a storyboard and it works about right half the time. The other half of the time, the rectangle drawn is too high or too low:
The strange thing is that when I set the frame in my code using this custom view, I print the frame right after I set it and I get this in the console:
2013-05-08 15:26:19.602 erodr[35723:c07] Post “Test post”: locationBoxedView.frame origin: {233, 29}, size: {75, 19}
I partially override the setFrame: method in my custom view just to print the new frame. This is what I do:
- (void)setFrame:(CGRect)frame
{
[super setFrame:frame];
NSLog(@"Frame set to %@", NSStringFromCGRect(frame));
}
And this is what I get in the console:
2013-05-08 15:26:19.603 erodr[35723:c07] Frame set to {{108, 40}, {46, 22}}
2013-05-08 15:26:19.603 erodr[35723:c07] Frame set to {{233, 18}, {75, 19}}
I believe the first "Frame set" is called when a new instance of the tableview cell is created from the storyboard. But how is the second setFrame: call ends with setting the frame to 233, 18 when the calling code sets it to 233,29?
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
Logiciels Nemesys Software 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