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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:51:16+00:00 2026-05-31T04:51:16+00:00

I’m trying to create horizontal scroll view(s). Each view containing one image. [done] Initially

  • 0

I’m trying to create horizontal scroll view(s). Each view containing one image. [done]

Initially when app is opened I’d display couple of images i.e 3, so user can scroll back and forth between images. [done]

However I want to be able to go to another view controller and pick another image(s) maybe two for example and display five images in the scroll view instead of displaying 3 initially.

How would one do that? to “re-refresh” the initial scroll view ?

Update
Should I use delegate for this communication between view controllers? or how is this done?
1 main controller, other containing image selection?

This part above and much more explained by article here.(not advertising, I hope it will help someone as well).

Bounty update part 1 :

I think now that I found my way around delegates, I have additional question that I cannot find answer to, all examples I saw were about updating table views.

Bounty part 2 :
If I were to have a scrollview inside my view controller and some nsimages inside scroll view. i.e :

- (void)viewDidLoad {
    [super viewDidLoad];

    NSMutableArray *images = ...some images array;
    for (int i = 0; i < images.count; i++) {
        CGRect frame;
        frame.origin.x = self.scrollView.frame.size.width * i;
        frame.origin.y = 0;
        frame.size = self.scrollView.frame.size;

        UIImageView *subview = [[UIImageView alloc] initWithFrame:frame];
        subview.image = [images objectAtIndex:i];
        [self.scrollView addSubview:subview];
    }

    self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * images.count, self.scrollView.frame.size.height);
}

And let say my view controller implemented some delegate method didAddImage or didRemoveImage.

Meaning that about images array would get updated.

Actual bounty question :

How would one actually “tell” the view controller, O.K now your scrollview has one more image to display, please re-fresh or reload?

If I were to have a table view instead scroll view and was inserting images I’d do it something like this(in my delegate method) :

-(void) mockDelegatetablemethod:(...) ...{
 [self.images addObject:image];
    NSIndexPath *indexPath = 
     [NSIndexPath indexPathForRow:[self.images count] - 1 
       inSection:0];
    [self.tableView insertRowsAtIndexPaths:
      [NSArray arrayWithObject:indexPath] 
       withRowAnimation:UITableViewRowAnimationAutomatic];
    [self dismissViewControllerAnimated:YES completion:nil];
}

How would one do this to the scrollview?

Bounty update part 3:

This is “simple” case described above, naturally I’d have to support removing images also as well as if one wants to remove all images and add some new.

  • 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-31T04:51:17+00:00Added an answer on May 31, 2026 at 4:51 am

    How would one actually “tell” the view controller, O.K now your
    scrollview has one more image to display, please re-fresh or reload?

    Well, you would just add the new image as a subview of the scroll view. So something like:

    - (void)addImage:(UIImage*)image {
        [images addObject:image];
    
        CGRect frame;
        frame.origin.x = self.scrollView.frame.size.width * images.count;
        frame.origin.y = 0;
        frame.size = self.scrollView.frame.size;
    
        UIImageView *subview = [[UIImageView alloc] initWithFrame:frame];
        subview.image = image;
        [self.scrollView addSubview:subview];
    
        self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * images.count, self.scrollView.frame.size.height);
    }
    

    Or you could have a method that goes and “resets” the scroll view by removing all subviews and then re-adds all the images in your images array. Then call this method in viewDidLoad instead of your code there so that you’re not duplicating code.

    Basically, there’s no silver bullet here. You roll your own.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.