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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:57:09+00:00 2026-05-23T08:57:09+00:00

In my app I have a table view and 4 images view in one

  • 0

In my app I have a table view and 4 images view in one row. When I scroll the table view then cell for row at index path method is again called and then the app crashes. How can I prevent table view reloading when scrolling. My part of code is :-

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = nil;
    static NSString *AutoCompleteRowIdentifier = @"AutoCompleteRowIdentifier";


    cell = [tableView dequeueReusableCellWithIdentifier:AutoCompleteRowIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AutoCompleteRowIdentifier] autorelease];

        for (int i=0; i <= [wordsInSentence count]; ++i) {
            UIImageView *imageView1 = [[[UIImageView alloc] initWithFrame:CGRectMake(30+90*(i%4), 15, 80, 100)] autorelease] ;
            imageView1.tag = i+1;

            [imageViewArray insertObject:imageView1 atIndex:i];
            [cell.contentView addSubview:imageView1];
        }

    }

    int photosInRow;

    if ( (indexPath.row < [tableView numberOfRowsInSection:indexPath.section] - 1) || ([wordsInSentence count] % 4 == 0) ) {
        photosInRow = 4;
    } else {
        photosInRow = [wordsInSentence count] % 4;
    }

    for ( int i = 1; i <=photosInRow ; i++ ){
        imageView = (UIImageView *)[cell.contentView viewWithTag:j];
        [self showImage:imageView];
    }

    return cell;
}

Please help. Any help will be appreciated.

Thanks,
Christy

  • 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-23T08:57:09+00:00Added an answer on May 23, 2026 at 8:57 am

    The only problem I see is this,

    for ( int i = 1; i <= photosInRow ; i++ ){
        imageView = (UIImageView *)[cell.contentView viewWithTag:j];
        [self showImage:imageView];
    }
    

    What is j here? I suggest you change that to i i.e.

    for ( int i = 1; i <=photosInRow ; i++ ){
        imageView = (UIImageView *)[cell.contentView viewWithTag:i];
        [self showImage:imageView];
    }
    

    As such only other flaw I see is the logic here,

    for (int i=0; i <= [wordsInSentence count]; ++i) {
        UIImageView *imageView1 = [[[UIImageView alloc] initWithFrame:CGRectMake(30+90*(i%4), 15, 80, 100)] autorelease] ;
        imageView1.tag = i+1;
    
        [imageViewArray insertObject:imageView1 atIndex:i];
        [cell.contentView addSubview:imageView1];
    }
    

    You only need to add 4 image views in a row. Not the the total number of image views in each row. This is flawed logic. Suggested update to

    for (int i = 0; i < 4; ++i) {
        UIImageView *imageView1 = [[[UIImageView alloc] initWithFrame:CGRectMake(30+90*(i%4), 15, 80, 100)] autorelease] ;
        imageView1.tag = i+1;
    
        int trueImageIndex = indexPath.row * 4 + i;
        [imageViewArray insertObject:imageView1 atIndex:trueImageIndex];
    
        [cell.contentView addSubview:imageView1];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my app I have a scroll view and four table views. Each time
In my iPhone app I have a table view where I add a tick
I have an app that presents Table View of different files. I have it
I have a working table view on my iphone app, and am implementing a
I have a categories table view controller. In my app, categories can have subcategories.
I am building an app using storyboard. I have added a table view to
I have an iPhone app which has a Table View-based data input screen with
So I have two TableView in one view of an iOS app. I have
Basically, I want to have an app with only one view that has an
Simple scenario: table view controller, with 5.000 rows. I have 5000 images name from

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.