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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:38:25+00:00 2026-05-30T12:38:25+00:00

Basically, I want to have an app with only one view that has an

  • 0

Basically, I want to have an app with only one view that has an image on it. I want to be able to swipe left or right and have the first image go out of the view and the second image to come in. The images are the same and I want it to look like they are connected (like scrolling down a rope where the pattern just repeats, but it looks like a constant scroll). I need it to be able to change the image or restart after a series of swipes. I know that I need to turn pagination ON in the UIScrollView, but I am new to iOS and am having trouble.

Ultimately, I want to have the iPhone vibrate every so-and-so swipes (and restart the pattern).

I’m sure that there are a lot of ways to do this (i.e. a TableView) so feel free to just point me in the direction of some references if the answer is tedious to explain.

Thanks!

FOLLOW UP:

I found an Apple example that did very nearly what I wanted to do. I made a lot of adjustments to it, but I’m banging my head against a wall trying to get the images to cycle. Here is what I think is the offending code, but I’m not sure what the solution is, as the ScrollView is functional, it just doesn’t reset the center to the current view. Any ideas?

    - (void)layoutScrollImages
{
        UIImageView *view = nil;
        NSArray *subviews = [scrollView1 subviews];

    // reposition all image subviews in a horizontal serial fashion
    CGFloat curXLoc = 0;
    for (view in subviews)
    {
        if ([view isKindOfClass:[UIImageView class]] && view.tag > 0)
        {
            CGRect frame = view.frame;
            frame.origin = CGPointMake(curXLoc, 0);
            view.frame = frame;

            curXLoc += (kScrollObjWidth);
        }
    }

    // set the content size so it can be scrollable
    [scrollView1 setContentSize:CGSizeMake((kNumImages * kScrollObjWidth), [scrollView1 bounds].size.height)];

}
  • 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-30T12:38:26+00:00Added an answer on May 30, 2026 at 12:38 pm

    I’d just use a UIScrollView. Set the contentWidth to be 3 times the width/height of the view (for 3 pages) and set the contentOffset to be the center ‘page’ (view.bounds.size.width or view.bounds.size.height depending on whether you’re scrolling horizontally/vertically respectively) . You’ll need to setup a delegate for the UIScrollView (probably the view controller) and implement - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView. This will be called when the scroll view has finished decelerating. Once it has finished decelerating, reset the contentOffset back to the center view. This should give the impression of an infinite scroll. You can also set a counter to increment in the scrollViewDidEndDecelerating method to increment the counter or initiate the vibration.

    You shouldn’t need to keep repositioning the images. Just set the images once in the scrollView:

    //Horizontal arrangement
    UIImage *image = [UIImage imageNamed:@"nameOfImage.png"];
    UIImageView *imageView1 = [[UIImageView alloc] initWithImage:image];
    UIImageView *imageView2 = [[UIImageView alloc] initWithImage:image];
    UIImageView *imageView3 = [[UIImageView alloc] initWithImage:image];
    NSArray *imageViews = [NSArray arrayWithObjects:imageView1, imageView2, imageView3];
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview: scrollView]; //This code assumes it's in a UIViewController
    CGRect cRect = scrollView.bounds;
    UIImageView *cView;
    for (int i = 0; i < imageViews.count; i++){
        cView = [imageViews objectAtIndex:i];
        cView.frame = cRect;
        [scrollView addSubview:cView];
        cRect.origin.x += cRect.size.width;
    }
    scrollView.contentSize = CGSizeMake(cRect.origin.x, scrollView.bounds.size.height);
    scrollView.contentOffset = CGPointMake(scrollView.bounds.size.width, 0); //should be the center page in a 3 page setup
    

    So the images are setup, you don’t need to mess with them anymore. Just reset the contentOffset when the scroll views stops (note: you need to make sure you’re the delegate of the scroll view or you’ll not receive the message when the scroll view stops):

    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
        scrollView.contentOffset = CGPointMake(scrollView.bounds.size.width, 0);
    }
    

    Please forgive any typos. I wrote it out by hand.

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

Sidebar

Related Questions

I have a partial view that I want to basically take care of itself
I have an app that has two buttons – one for email & one
I have an app that I want to be able to build two different
I have a really simple Rails app. Basically an article with comments. I want
I have an SPListItemCollection. I basically want to get one of the items (randomly)
I am working on an app (my first one), which is basically a TabBar
I have a web-app that has a master mysql db and four slave dbs.
I want to be able to have a table show only if there are
I have a counter in my app that has a reset button, but instead
Alright heres the deal. I have a sports app that i want to update

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.