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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:53:28+00:00 2026-05-26T06:53:28+00:00

I make an UITableview (with IB) in my application with 3 types of cell.

  • 0

I make an UITableview (with IB) in my application with 3 types of cell. All works fine except when i drag my tableview all become very slow. So if someone can help me to improve the performance of my app it’ll be cool.

My Code for the tableview :

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [[myData objectForKey:@"listnews"] count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 154;
    }
    if (indexPath.row == 1) {
        return 34;
    }
    else return 70;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    [myTextField resignFirstResponder];

    ListNewsCell *cCell = (ListNewsCell *)[myTable dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"cCellIdentifier%d",indexPath.row]];

    cCell = [[ListNewsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[NSString stringWithFormat:@"cCellIdentifier%d",indexPath.row]];

    if (indexPath.row == 0) {
        NSString * caroline = [[[myData objectForKey:@"listnews"] objectAtIndex:indexPath.row] objectForKey:@"urlimage"];
        cCell.c1Image1.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",caroline]]]];

        cCell.c1Image2.image = [UIImage imageNamed:@"barreNoireHub.png"];

        NSString * sophie = [[[myData objectForKey:@"listnews"] objectAtIndex:indexPath.row] objectForKey:@"titre"];
        NSString *itemTitle = sophie ? [sophie stringByConvertingHTMLToPlainText] : @"[No Title]";
        cCell.c1Label1.text = itemTitle;

        NSString * sonia = [[[myData objectForKey:@"listnews"] objectAtIndex:indexPath.row] objectForKey:@"extrait"];
        NSString *itemExtrait = sonia ? [sonia stringByConvertingHTMLToPlainText] : @"[No Title]";
        cCell.c1Label2.text = itemExtrait;
        }

    if (indexPath.row == 1) {        
        UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 34)];
        imageView.backgroundColor = [UIColor whiteColor];
        imageView.image = [UIImage imageNamed:@"barreSearchHub.png"];
        [cCell addSubview:imageView];
        [imageView release];

        UIView * insertView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 34)];
        myTextField = [[UITextField alloc] initWithFrame:CGRectMake(15, 6, 270, 25)];
        myTextField.placeholder = @"Recherche";
        myTextField.tag = 1;
        myTextField.delegate = self;
        myTextField.returnKeyType = UIReturnKeySearch;

        [insertView addSubview:myTextField];
        cCell.accessoryView = insertView;
    }

    if (indexPath.row > 1) {
        cCell.c2Image1.image = [UIImage imageNamed:@"cellM.png"];

        NSString * caroline = [[[myData objectForKey:@"listnews"] objectAtIndex:indexPath.row] objectForKey:@"urlimage"];
        cCell.c2Image2.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",caroline]]]];

        NSString * sophie = [[[myData objectForKey:@"listnews"] objectAtIndex:indexPath.row] objectForKey:@"titre"];
        NSString *itemTitle = sophie ? [sophie stringByConvertingHTMLToPlainText] : @"[No Title]";
        cCell.c2Label1.text = itemTitle;

        NSString * sonia = [[[myData objectForKey:@"listnews"] objectAtIndex:indexPath.row] objectForKey:@"extrait"];
        NSString *itemExtrait = sonia ? [sonia stringByConvertingHTMLToPlainText] : @"[No Title]";
        cCell.c2Label2.text = itemExtrait;
    }
    return cCell;
}

The code of the UITableViewCell:

#import "ListNewsCell.h"

@implementation ListNewsCell

@synthesize c1Image1, c1Image2, c1Label1, c1Label2;
@synthesize c2Image1, c2Image2, c2Label1, c2Label2;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        c1Image1 = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,154)];
        c1Image1.backgroundColor = [UIColor clearColor];
        [self addSubview:c1Image1];
        [c1Image1 release];

        c1Image2 = [[UIImageView alloc] initWithFrame:CGRectMake(0,98,320,56)];
        c1Image2.backgroundColor = [UIColor clearColor];
        [self addSubview:c1Image2];
        [c1Image2 release];

        c1Label1 = [[UILabel alloc] initWithFrame:CGRectMake(5, 100, 310, 20)];
        c1Label1.font = [UIFont fontWithName:@"Arial-BoldMT" size:14];
        c1Label1.textColor = [UIColor whiteColor];
        c1Label1.backgroundColor = [UIColor clearColor];
        [self addSubview:c1Label1];

        c1Label2 = [[UILabel alloc] initWithFrame:CGRectMake(5, 112, 310, 45)];
        c1Label2.font = [UIFont fontWithName:@"Arial" size:12];
        c1Label2.textColor = [UIColor whiteColor];
        c1Label2.numberOfLines = 2;
        c1Label2.backgroundColor = [UIColor clearColor];
        [self addSubview:c1Label2];

        c2Image1 = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,70)];
        c2Image1.backgroundColor = [UIColor clearColor];
        [self addSubview:c2Image1];
        [c2Image1 release];

        c2Label1 = [[UILabel alloc] initWithFrame:CGRectMake(105, 8, 180, 20)];
        c2Label1.font = [UIFont fontWithName:@"Arial-BoldMT" size:14];
        c2Label1.textColor = [UIColor blackColor];
        c2Label1.backgroundColor = [UIColor clearColor];
        [self addSubview:c2Label1];

        c2Label2 = [[UILabel alloc] initWithFrame:CGRectMake(105, 25, 180, 45)];
        c2Label2.font = [UIFont fontWithName:@"Arial" size:12];
        c2Label2.textColor = [UIColor blackColor];
        c2Label2.numberOfLines = 2;
        c2Label2.backgroundColor = [UIColor clearColor];
        [self addSubview:c2Label2];

        c2Image2 = [[UIImageView alloc] initWithFrame:CGRectMake(20,10,75,55)];
        c2Image2.backgroundColor = [UIColor clearColor];
        [self addSubview:c2Image2];
        [c2Image2 release];
    }
    return self;
}

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

- (void)dealloc
{
    [super dealloc];
}

@end

Thanks to all !

  • 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-05-26T06:53:29+00:00Added an answer on May 26, 2026 at 6:53 am

    The following line causes the big delay:

    cCell.c2Image2.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",caroline]]]];
    

    Everytime one of these cells will be loaded, it will make a URL Request. Try to preload a bunch of the data instead of requesting it per cell.

    Load the image once, make it a class variable, then just reuse its pointer like:

    cCell.c2Image2.image = preloadedImage;

    Declare in your .h file:

    UIImage * preloadedImage;
    

    And in the – (void) loadView -method put:

    preloadedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",caroline]]]];
    

    Also mind that as jrturton wrote, you want to reuse your dequeued cells for the extra performance boost.

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

Sidebar

Related Questions

Did actually someone make already a tutorial that shows how to customize an UITableView?
I have a UITableView in iPhone with enough cell to make it scrollable. I
I am trying make a segue call in a tableview , but the application
I have implemented Add to Favourites functionality for my iPhone application. It works fine
I am just curious. I make a few UITableView. In all cases, if I
How can I make an iphone application that uses a UITableView but so the
I want to make the grouped UITableView transparent. I partially succeded with the following
Apple says about the UITableView -beginUpdates -endUpdates block: If you do not make the
i have made iPhone Application and i want to make it iPad Compatible without
Normally, the UITableView is something like this: [ cell 1 ] [ cell 2

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.