Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8620147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:30:52+00:00 2026-06-12T06:30:52+00:00

I have made major changes and setup a custom class for the TableView Cell.

  • 0

I have made major changes and setup a custom class for the TableView Cell.

Cell.h

#import <UIKit/UIKit.h>

@interface Cell : UITableViewCell
@property (nonatomic, retain) UILabel *month;
@property (nonatomic, retain) UILabel *date;
@end

Cell.m

#import "Cell.h"

@implementation Cell
@synthesize date, month;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageView.frame = CGRectMake(1,1,69,69);

    float limgW =  self.imageView.image.size.width;
    if(limgW > 0) {
        UIFont *cellFont3 = [UIFont fontWithName:@"ArialRoundedMTBold" size:9];
        UIFont *cellFont4 = [UIFont fontWithName:@"ArialRoundedMTBold" size:18];
        self.textLabel.frame = CGRectMake(82,0,228,53);
        self.detailTextLabel.frame = CGRectMake(82, 20, 228, 53);
        self.month = [[UILabel alloc] initWithFrame:CGRectMake(8, 10, 53, 21)];
        self.month.font = cellFont3;
        self.month.textAlignment = UITextAlignmentCenter;
        self.month.backgroundColor = [UIColor clearColor];

        self.date = [[UILabel alloc] initWithFrame:CGRectMake(11, 21, 50, 45)];
        self.date.backgroundColor = [UIColor clearColor];
        self.date.font = cellFont4;
        self.date.textAlignment = UITextAlignmentCenter;

    }
}
@end

Then in my TableView code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    Cell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[Cell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

    }


    RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];

    NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    [dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
    [dateFormatter setDateStyle:NSDateFormatterShortStyle];

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM"];
    NSString *monthfromdate = [formatter stringFromDate:entry.articleDate];
    NSLog(@"%@", monthfromdate);
    [formatter release];

    NSDateFormatter *formatter2 = [[NSDateFormatter alloc] init];
    [formatter2 setDateFormat:@"dd"];
    NSString *datefromdate = [formatter2 stringFromDate:entry.articleDate];
    NSLog(@"%@", datefromdate);
    [formatter2 release];

    if ([monthfromdate isEqualToString:@"01"]) {
        self.currentmonth = @"January";
    }
    if ([monthfromdate isEqualToString:@"02"]) {
        self.currentmonth = @"February";
    }
    if ([monthfromdate isEqualToString:@"03"]) {
        self.currentmonth = @"March";
    }
    if ([monthfromdate isEqualToString:@"04"]) {
        self.currentmonth = @"April";
    }
    if ([monthfromdate isEqualToString:@"05"]) {
        self.currentmonth = @"May";
    }
    if ([monthfromdate isEqualToString:@"06"]) {
        self.currentmonth = @"June";
    }
    if ([monthfromdate isEqualToString:@"07"]) {
        self.currentmonth = @"July";
    }
    if ([monthfromdate isEqualToString:@"08"]) {
        self.currentmonth = @"August";
    }
    if ([monthfromdate isEqualToString:@"09"]) {
        self.currentmonth = @"September";
    }
    if ([monthfromdate isEqualToString:@"10"]) {
        self.currentmonth = @"October";
    }
    if ([monthfromdate isEqualToString:@"11"]) {
        self.currentmonth = @"November";
    }
    if ([monthfromdate isEqualToString:@"12"]) {
        self.currentmonth = @"December";
    }


    NSString *currentday = datefromdate;


    NSString *articleDateString = [dateFormatter stringFromDate:entry.articleDate];
    UIFont *cellFont = [UIFont fontWithName:@"ArialRoundedMTBold" size:15];
    UIFont *cellFont2 = [UIFont fontWithName:@"ArialRoundedMTBold" size:12];

    cell.imageView.image = [UIImage imageNamed:@"calendar1.png"];
    cell.imageView.contentMode = UIViewContentModeScaleAspectFit;



    cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ - %@", articleDateString, entry.blogTitle];
    cell.detailTextLabel.textColor = [UIColor grayColor];
    cell.detailTextLabel.font = cellFont2;

    cell.textLabel.text = entry.articleTitle;
    cell.textLabel.font = cellFont;
    cell.month.text = currentmonth;
    cell.date.text = currentday;
    return cell;
}

This solves problems with repeats, or labels being written on top of each other, but only the cell.textLabel shows anything. Nothing appears on the detailTextLabel or the other 2 labels I set up.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:30:53+00:00Added an answer on June 12, 2026 at 6:30 am

    Your approach is incorrect. When cells are being reused, it does not necessarily means that the cell on index path {0,1} will be reused the next time that this particular index path cell becomes visible. A cell of the same identifier will be used, and it might contain the data of a different cell at a different index path. Your approach should be to dequeue or initialize the cell depending on the cell existence after dequeing, but always assign data on the cell based on the index path .

    A few words of advice: do not create/release NSDateFormatter objects inside the cellForRowAtIndexPath method. It will give you performance issues. Also, for organization purposes, please subclass UITableViewCell and create the interface properly. Adding them on the fly is messy and confusing.

    Also, looking at what you are trying to do, you might want to take a look at NSDateFormatter’s monthSymbols and weekdaySymbols method, and NSDateComponent documentation. You can get the months and day information instead of having 12 “ifs” to get the months.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made my own exception class which derives from runtime_error and is getting
Apparently, Windows made some major changes to the audio architecture in Windows Vista. As
UPDATE: I made major changes to this post - check the revision history for
I have made a major refactoring of some code, and in the process I
I have made a jQuery toggle for a menu that I had in mind.
I have made an application for IPad in objective C. In this I am
i have made an application having entity framewrok. It is wpf application, now it
I have made a code that read data from flash Nand (without filesystem). fd
I have made a cart and the cart has remove item button, but the
I have made a website using( Asp.net, c# ) and its content in English

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.