I have a UITableView with a custom UITableViewCell that I created in the InterfaceBuilder. I added an UIView to the UITableViewCell and also added an Outlet for it. Now I need to know it´s position in the specific UITableViewCell.
I wrote the following code in my custom UITableViewCell
WorkentryCell.h
#import <UIKit/UIKit.h>
@interface WorkentryCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIView *view1;
@end
WorkentryCell.m
#import "WorkentryCell.h"
@implementation WorkentryCell
@synthesize view1;
-(id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self) {
NSLog(@"%f, %f", self.view1.bounds.size.height, self.view1.bounds.size.width);
NSLog(@"%f, %f", self.view1.bounds.origin.x, self.view1.bounds.origin.y);
}
return self;
}
-(void)setNeedsDisplay
{
NSLog(@"%f, %f", self.view1.bounds.size.height, self.projectLabel.bounds.size.width);
NSLog(@"%f, %f", self.view1.bounds.origin.x, self.projectLabel.bounds.origin.y);
}
but everything I get is:
2012-11-14 15:01:43.943 TestApp[883:907] 0.000000, 0.000000
2012-11-14 15:01:43.944 TestApp[883:907] 0.000000, 0.000000
Can you please tell me why there is no information about position and size of the UIView?
Thanks
Philipp
You won’t have valid size in the init method. You should put this code in the setNeedsDisplay.