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 8303023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:25:35+00:00 2026-06-08T17:25:35+00:00

I have problem with a UITableview, I’m fetching some data and displaying it in

  • 0

I have problem with a UITableview, I’m fetching some data and displaying it in a custom cell views, almost everything is going well except two issues :

  • When I scroll down, some new cells show content from previous cells (especially the TextView cellText)
  • sometime the app crashes with [UIImageView setText:]: unrecognized selector sent to instance at line :
    [cellText setText:postText];

Here is my cellForRowAtIndexPath method :

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


NSString *PostCellIdentifier;

Post *info = [posts objectAtIndex:indexPath.row];
NSString *PostType = info.type;

if([PostType isEqualToString:@"quote"]) {

    PostCellIdentifier = @"NewsQuoteCell";

} else if([PostType isEqualToString:@"article"]) {

    PostCellIdentifier = @"NewsArticleCell";

} else if([PostType isEqualToString:@"picture"]) {

    PostCellIdentifier = @"NewsPictureCell";

} else if([PostType isEqualToString:@"video"]) {

    PostCellIdentifier = @"NewsVideoCell";

} else if([PostType isEqualToString:@"audio"]) {

    PostCellIdentifier = @"NewsAudioCell";

}    


NewsQuoteCell *cell = [tableView dequeueReusableCellWithIdentifier:PostCellIdentifier];

if (cell == nil) {
    cell = [[NewsQuoteCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:PostCellIdentifier];
}



UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:1];
[cellLabel setText:info.masjid_name];

UILabel *cellDate = (UILabel *)[cell.contentView viewWithTag:2];
[cellDate setText:info.date];


UITextView *cellText = (UITextView *)[cell.contentView viewWithTag:5];
NSString *postText = info.title;
[postText stringByDecodingHTMLEntities];    
if ([postText length] > 300) { 
    postText = [postText substringToIndex:300];
    postText = [postText stringByAppendingString:@"..."];
}
[cellText setText:postText];

CGRect frame = cellText.frame;
frame.size.height = cellText.contentSize.height;
cellText.frame = frame;


UIImageView *cellImage = (UIImageView *)[cell.contentView viewWithTag:3];
NSString *imagePath = info.masjid_thumb;
[cellImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@", imagePath]]];

cell.backgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];  
cell.selectedBackgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];






if([PostType isEqualToString:@"article"]) {


    cellText.userInteractionEnabled = YES;
    UITapGestureRecognizer *pgrText = [[UITapGestureRecognizer alloc] 
                                       initWithTarget:self action:@selector(handleTapArticle:)];
    [cellText setTag:indexPath.row];
    [cellText addGestureRecognizer:pgrText];



    UIImageView *cellMedia = (UIImageView *)[cell.contentView viewWithTag:10];

    cellMedia.userInteractionEnabled = YES;
    UITapGestureRecognizer *pgr = [[UITapGestureRecognizer alloc] 
                                   initWithTarget:self action:@selector(handleTapArticle:)];
    [cellMedia setTag:indexPath.row];
    [cellMedia addGestureRecognizer:pgr];

} else if ([PostType isEqualToString:@"video"]) {


    cellText.userInteractionEnabled = YES;
    UITapGestureRecognizer *pgrText = [[UITapGestureRecognizer alloc] 
                                       initWithTarget:self action:@selector(handleTap:)];
    [cellText setTag:indexPath.row];
    [cellText addGestureRecognizer:pgrText];



    UIImageView *cellMedia = (UIImageView *)[cell.contentView viewWithTag:10];

    cellMedia.userInteractionEnabled = YES;
    UITapGestureRecognizer *pgr = [[UITapGestureRecognizer alloc] 
                                   initWithTarget:self action:@selector(handleTap:)];
    [cellMedia setTag:indexPath.row];
    [cellMedia addGestureRecognizer:pgr];


} else if ([PostType isEqualToString:@"audio"]) {


    cellText.userInteractionEnabled = YES;
    UITapGestureRecognizer *pgrText = [[UITapGestureRecognizer alloc] 
                                       initWithTarget:self action:@selector(handleTap:)];
    [cellText setTag:indexPath.row];
    [cellText addGestureRecognizer:pgrText];


    UIImageView *cellMedia = (UIImageView *)[cell.contentView viewWithTag:10];

    cellMedia.userInteractionEnabled = YES;
    UITapGestureRecognizer *pgr = [[UITapGestureRecognizer alloc] 
                                   initWithTarget:self action:@selector(handleTap:)];
    [cellMedia setTag:indexPath.row];
    [cellMedia addGestureRecognizer:pgr];


} else if ([PostType isEqualToString:@"picture"]) {

    cellText.layer.shadowColor = [[UIColor blackColor] CGColor];
    cellText.layer.shadowOffset = CGSizeMake(1.0f, 1.0f);
    cellText.layer.shadowOpacity = 0.5f;
    cellText.layer.shadowRadius = 0.5f;

    UIImageView *cellMedia = (UIImageView *)[cell.contentView viewWithTag:7];

    NSString *mediaPath = info.media;


   NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:mediaPath]];
    AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:request success:^(UIImage *image) {

        UIImage* scaled2 = [image scaleToFitSize:(CGSize){284, 284}];
        [cellMedia setImage:scaled2];

        CGRect frame1 = cellMedia.frame;
        frame1.size.width = 284;
        frame1.size.height = scaled2.size.height;
        cellMedia.frame = frame1;

    }];
    [operation start];



    cellMedia.userInteractionEnabled = YES;
    UITapGestureRecognizer *pgr = [[UITapGestureRecognizer alloc] 
                                   initWithTarget:self action:@selector(handleTapPicture:)];
    [cellMedia setTag:indexPath.row];
    [cellMedia addGestureRecognizer:pgr];




    if ([postText length] > 300) { 
        postText = [postText substringToIndex:300];
        postText = [postText stringByAppendingString:@"..."];
    }
    [cellText setText:postText];

    CGRect frame = cellText.frame;

    frame.size.height = cellText.contentSize.height;
    frame.origin.y = cellMedia.frame.origin.y + (cellMedia.frame.size.height - cellText.contentSize.height);
   cellText.frame = frame;

}


return cell;


}

Any help please ?

  • 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-08T17:25:36+00:00Added an answer on June 8, 2026 at 5:25 pm

    It looks like you have a subclass of UITableViewCell called NewsQuoteCell. You can override the prepareForReuse method in the NewsQuoteCell class to fix your new cell shows content of previous cell issue. The other issue seemed to have to do with the your tag for view number 5 was not a UITextView but a UIImageView. I would double check your NewsQuoteCell’s implementation file.

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

Sidebar

Related Questions

I have a problem displaying UITableView : Some cells are empty, and content in
I have a problem with data in UITableView. I have UIViewController, that contains UITableView
I have a strange problem with UITableView and UITextField inside the cell (as subview).
I have a problem with my custom tableview cell. When I want to put
I have a problem with a tableview and a custom cell. I have the
I have a problem with Custom cell on story board. I need to access
I have following problem: I've got an UITableView with 7 custom cells. Each of
After use UITableView Style Grouped, it have a problem when use selectedBackgroundView with custom
i have a problem while loading a UITableView on UITabBarController, i got this error
I have problem while loading data into html select when users press or click

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.