Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static NSString *CellIdentifier = @"Cell";
- UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
- //code STATS here : initializing here for cells background view & selection back ground view
- cell.backgroundView =
- [[[UIImageView alloc] init] autorelease];
- cell.selectedBackgroundView =
- [[[UIImageView alloc] init] autorelease];
- //code ENDS HERE of initializing
- //custom label
- UIImage *indicatorImage = [UIImage imageNamed:@"indicator.png"];
- cell.accessoryView =
- [[[UIImageView alloc]
- initWithImage:indicatorImage]
- autorelease];
- const CGFloat LABEL_HEIGHT = 20;
- UIImage *image = [UIImage imageNamed:@"filter.png"];//this image is on top //left of section zero rows
- //
- // Create the label for the top row
- //
- topLabel =
- [[[UILabel alloc]
- initWithFrame:
- CGRectMake(
- image.size.width + 2.0 * cell.indentationWidth,
- 0.5 * (aTableView.rowHeight - 2 * LABEL_HEIGHT),
- aTableView.bounds.size.width -
- image.size.width - 4.0 * cell.indentationWidth
- - indicatorImage.size.width,
- LABEL_HEIGHT)]
- autorelease];
- [cell.contentView addSubview:topLabel];
- //
- // Configure the properties for the text that are the **SAME** on every row
- //
- topLabel.tag = TOP_LABEL_TAG;
- topLabel.backgroundColor = [UIColor clearColor];
- topLabel.textColor = [UIColor colorWithRed:0.25 green:0.0 blue:0.0 alpha:1.0];
- topLabel.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
- topLabel.font = [UIFont systemFontOfSize:[UIFont labelFontSize]];
- //testing:
- topLabel.text=@"test1";
- //
- // Create the label for the top row of text
- //
- bottomLabel =
- [[[UILabel alloc]
- initWithFrame:
- CGRectMake(
- image.size.width + 2.0 * cell.indentationWidth,
- 0.5 * (aTableView.rowHeight - 2 * LABEL_HEIGHT) + LABEL_HEIGHT,
- aTableView.bounds.size.width -
- image.size.width - 4.0 * cell.indentationWidth
- - indicatorImage.size.width,
- LABEL_HEIGHT)]
- autorelease];
- [cell.contentView addSubview:bottomLabel];
- //
- // Configure the properties for the text that are the same on every row
- //
- bottomLabel.tag = BOTTOM_LABEL_TAG;
- bottomLabel.backgroundColor = [UIColor clearColor];
- bottomLabel.textColor = [UIColor colorWithRed:0.25 green:0.0 blue:0.0 alpha:1.0];
- bottomLabel.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
- bottomLabel.font = [UIFont systemFontOfSize:[UIFont labelFontSize] - 2];
- bottomLabel.text=@"test2";
- }
- //testing for section 2
- //this image is on top left of section one rows
- UIImage *image1 = [UIImage imageNamed:@"akshardham.jpg"];
- topLabel1 =
- [[[UILabel alloc]
- initWithFrame:
- CGRectMake(
- image1.size.width + 2.0 * cell.indentationWidth,
- 0.5 * (aTableView.rowHeight - 2 * LABEL_HEIGHT),
- aTableView.bounds.size.width -
- image1.size.width - 4.0 * cell.indentationWidth
- - indicatorImage.size.width,
- LABEL_HEIGHT)]
- autorelease];
- [cell.contentView addSubview:topLabel1];
- topLabel1.tag = TOP_LABEL_TAG1;
- topLabel1.backgroundColor = [UIColor clearColor];
- topLabel1.textColor = [UIColor colorWithRed:0.25 green:0.0 blue:0.0 alpha:1.0];
- topLabel1.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
- topLabel1.font = [UIFont systemFontOfSize:[UIFont labelFontSize]];
- //testing:
- topLabel1.text=@"test2section";
- }
- }
- else
- {
- topLabel = (UILabel *)[cell viewWithTag:TOP_LABEL_TAG];
- bottomLabel = (UILabel *)[cell viewWithTag:BOTTOM_LABEL_TAG];
- topLabel1 = (UILabel *)[cell viewWithTag:TOP_LABEL_TAG1];
- }
- if (cell == nil) {
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString * MYTableViewCellIdentifier = @"MYTableViewCellIdentifier";
- MyTableViewCell * cell = (MyTableViewCell *)[tableView dequeueReusableCellWithIdentifier:MYTableViewCellIdentifier];
- if (cell == nil) {
- // Create the cell
- // Global layout for the cell
- }
- // Customization code
- return cell;
- }
Add Comment
Please, Sign In to add comment