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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:26:55+00:00 2026-06-12T10:26:55+00:00

I’m adding AsyncImageView into UIScrollView to load images from web, its working fine, there

  • 0

I’m adding AsyncImageView into UIScrollView to load images from web, its working fine, there are 8 images i’ve added. Problem is of paging I’ve enabled pagingEnable to YES but it won’t come as per I want, I’m trying to setting it contentOffset with different x but it won’t any effects. I want that each image should come in center of UIScrollView when I scroll or choose next or previous option.

This is the code where I’m adding images to UIScrollView

arrImgUrls is an NSArray

_currentImage, _imageCount are integers

-(void)setImagesToScrollView
{
    [btnPrev setEnabled:NO];

    _currentImage = 0;

    _imageCount = [arrImgUrls count];

    int x=20;
    int y=0;
    int w=213;
    int h=160;

    for (int i=0; i<[arrImgUrls count]; i++) 
    {
        AsyncImageView *asyncImageView = [[AsyncImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
        [asyncImageView setDelegate:self];
        [asyncImageView.layer setMasksToBounds:YES];        
        NSString *urlImage = [arrImgUrls objectAtIndex:i];
        NSURL *url = [NSURL URLWithString:urlImage];
        [asyncImageView loadImageFromURL:url];
        [asyncImageView release];
        [scrollImages addSubview:asyncImageView];
        x=(x+w)+10;
    }

    scrollImages.contentSize=CGSizeMake(x, scrollImages.frame.size.height);
}

This is code I used to show previous or next images in UIScrollView.

-(IBAction)prevImage:(id)sender
{    
    _currentImage--;

    [btnNext setEnabled:YES];
    
    if (_currentImage<=0)
    {
        _currentImage = 0;
        [btnPrev setEnabled:NO];
    }

    [scrollImages setContentOffset:CGPointMake((_currentImage*imageWidth)+10, 0) animated:NO];
}

-(IBAction)nextImage:(id)sender
{    
    _currentImage++;

    [btnPrev setEnabled:YES];

    if (_imageCount-1 == _currentImage)
    {
        [btnNext setEnabled:NO];
    }

    [scrollImages setContentOffset:CGPointMake(_currentImage*imageWidth, 0) animated:NO];
}

All images loaded and added to UIScrollView only problem is to show it in center when user scrolls or do previous or next.

Please point me where I’m doing wrong?

Thanks!

  • 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-12T10:26:57+00:00Added an answer on June 12, 2026 at 10:26 am

    First of all make sure that _currentImage is maintain properly or not?

    Now try following for next image

    CGRect frame;
    frame.origin.x = (imageWidth * _currentImage) +10;
    frame.origin.y = 0;
    frame.size = self.scrollView.frame.size;
    [self.scrollView scrollRectToVisible:frame animated:YES]; // NO if you don't want animation
    

    Instead of this line

    [scrollImages setContentOffset:CGPointMake(_currentImage*imageWidth+10, 0) animated:NO];
    

    & for previous image

    CGRect frame;
    frame.origin.x = (imageWidth * _currentImage) - 10;
    frame.origin.y = 0;
    frame.size = self.scrollView.frame.size;
    [self.scrollView scrollRectToVisible:frame animated:YES]; // NO if you don't want animation
    

    and here one nice example just like you want

    Image gallary

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was

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.