I am trying to add a 2nd UILabel to a UITabView below the main label to add more description to what you will find when you tap on the table view (like the mail preview below the main title of the email to provide more info on its contents).
The problem with the UILabel is that its not adding the 2nd label to the table view cell.
The code is:
The item in the code called "label" is my main label with a list of stores. The "info label" is what I want to add to the table view. The infoLabel reads data from store.info (that of which reads data from a .plist file).
Any ideas would be appreciated.
The problem with the UILabel is that its not adding the 2nd label to the table view cell.
The code is:
Code:
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
store = nil;
storeTileView = nil;
labelView = nil;
infoLabel = nil;
// create the storeTileView and the labelView
// both of these will be laid out again by the layoutSubviews method
AtomicstoreTileView *tileView = [[AtomicstoreTileView alloc] initWithFrame:CGRectZero];
self.storeTileView = tileView;
[self.contentView addSubview:tileView];
[tileView release];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
// set the label view to have a clear background and a 20 point font
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:12.5];
self.labelView = label;
[self.contentView addSubview:label];
[label release];
UILabel *infoLabel = [[UILabel alloc] initWithFrame:CGRectZero];
// set the label view to have a clear background and a 20 point font
infoLabel .backgroundColor = [UIColor clearColor];
infoLabel .font = [UIFont boldSystemFontOfSize:1];
self.infoLabel = label;
[self.contentView addSubview:infoLabel ];
[infoLabel release];
// add both the label and storeTile to the TableViewCell view
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
// determine the content rect for the cell. This will change depending on the
// style of table (grouped vs plain)
CGRect contentRect = self.contentView.bounds;
// position the image tile in the content rect.
CGRect storeTileRect = self.contentView.bounds;
storeTileRect.size = [AtomicstoreTileView preferredViewSize];
storeTileRect = CGRectOffset(storeTileRect,10,3);
storeTileView.frame = storeTileRect;
// position the elment name in the content rect
CGRect labelRect = contentRect;
labelRect.origin.x = labelRect.origin.x+56;
labelRect.origin.y = labelRect.origin.y+3;
labelView.frame = labelRect;
CGRect labelRect2 = contentRect;
labelRect2.origin.x = labelRect2.origin.x+65;
labelRect2.origin.y = labelRect2.origin.y+3;
infoLabel.frame = labelRect2;
}
- (void)dealloc {
[store release];
[storeTileView release];
[labelView release];
[infoLabel release];
[super dealloc];
}
- (void)setstore:(Atomicstore *)anstore {
if (anstore != store) {
[store release];
[anstore retain];
store = anstore;
}
storeTileView.store = store;
labelView.text = store.name;
infoLabel.text = store.info;
[storeTileView setNeedsDisplay];
[labelView setNeedsDisplay];
[infoLabel setNeedsDisplay];
}
The item in the code called "label" is my main label with a list of stores. The "info label" is what I want to add to the table view. The infoLabel reads data from store.info (that of which reads data from a .plist file).
Any ideas would be appreciated.