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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:52:25+00:00 2026-06-15T18:52:25+00:00

I’m developing an app that i need to load many images in a view

  • 0

I’m developing an app that i need to load many images in a view using Xcode 4.5.2

So, At the top, I have a UIView, inside of this UIView, i have UIScrollView to display many images,i’m using this UIScrollView in pagingEnabled mode. As i have many images to load, i know that it cannot be possible to load at once. So, i decided to add or remove if need be.

When the app starts, i’ve loaded three images in UIScrollView, when user passes to image 2,
i want to remove image 0 from UIScrollView.When i try to remove the image 0,i got totally white screen.The funny part is that if i dont try to remove image 0,when user passes to image 3, i want to load a new image(image 4) to UIScrollView, and remove image 1.So far, I’m able to do this. Basically,my apps works just fine, but when i want to remove the first(at index 0)image,I got totally white screen on the screen.

Do you have any idea why i’m getting this behaviour ? I got neither warning,nor error. How is it possible that i’m able to remove all the other images but not the image 0 ?

Thank you.

     -(void)scrollViewDidScroll:(UIScrollView *)scrollView
{ 
static NSInteger currentPage = 0 ;
CGFloat pageWidth = self.scrollView.frame.size.width ;
float fractionalPage = self.scrollView.contentOffset.x / pageWidth ;
NSLog(@"%f",fractionalPage);
if(fractionalPage == currentPage+1)
{
    NSLog(@"Swipe Left");
    currentPage++;
    NSLog(@"Current page :%d",currentPage);

    [self setLayoutImages:kLeft] ;
}
else if(fractionalPage+1 ==currentPage)
{
    NSLog(@"Swipe Right");
    currentPage--;
    NSLog(@"Current page :%d",currentPage);
    [self setLayoutImages:kRight];
}

}

-(void)setLayoutImages:(Direction )direction
{
int currentPage = self.scrollView.contentOffset.x / scrollViewWidth ;
if(direction == kLeft)
{
    self.scrollView.contentSize = CGSizeMake(((currentPage+2) * scrollViewWidth), 350.0f);
    if(![self.scrollView viewWithTag:currentPage+1])
    {
        NSString *imageName = @"iPhone.png" ;
        UIImage *image = [UIImage imageNamed:imageName];
        UIImageView *imageView = [[UIImageView alloc]initWithImage:image ] ;
        imageView.tag  = currentPage+1 ;
        CGRect frame = imageView.frame ;
        frame.size.height = imageHeight;
        frame.size.width = scrollViewWidth ;
        frame.origin.x = (currentPage+1) * scrollViewWidth ;
        frame.origin.y = 0 ;
        imageView.frame = frame ;
        if (currentPage>2) { //To be able to remove the first image,i need to add equal here,but i got white screen.
            [[self.scrollView viewWithTag:(currentPage -2)]removeFromSuperview ] ;            }
        [self.scrollView addSubview:imageView ] ;
    }
}
else if(direction == kRight)
{
    if(![self.scrollView viewWithTag:currentPage-1] && currentPage >0)
    {
        NSString *imageName = @"gs.jpeg";
        UIImage *image = [UIImage imageNamed:imageName];
        UIImageView *imageView = [[UIImageView alloc]initWithImage:image ];
        imageView.tag = currentPage-1 ;
        CGRect frame = imageView.frame ;
        frame.size.height = imageHeight ;
        frame.size.width = scrollViewWidth ;
        frame.origin.x = (currentPage-1)*scrollViewWidth ;
        frame.origin.y = 0 ;
        imageView.frame = frame ;
        [[self.scrollView viewWithTag:currentPage+2]removeFromSuperview ] ;
        [self.scrollView addSubview:imageView ];
    }
}

}

  • 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-15T18:52:28+00:00Added an answer on June 15, 2026 at 6:52 pm

    Try making your views start with a tag of 1 not 0, as 0 is the default for an untagged view if i remember correctly, and this might be causing the problem

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I need a function that will clean a strings' special characters. I do NOT

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.