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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:26:09+00:00 2026-05-26T14:26:09+00:00

I have a horizontal UIScrollview set up (meaning its not one that scrolls up

  • 0

I have a horizontal UIScrollview set up (meaning its not one that scrolls up and down but one that only scrolls left-right) and upon the app launching, I want this scrollview to scroll itself left, then right – kind of “demonstrating” its ability to scroll – and finally then stop, letting the user then take over and control the scroll manually with their finger.
Everything works – except for this on-load left-right demo-scrolling.

I’m not using Interface Builder for any of this, I’m doing everything with code:

//(this is in viewDidLoad:)
// Create the scrollView:
UIScrollView *photosScroll = [[UIScrollView alloc] initWithFrame: CGRectMake(0, 0, 320, 200)];
[photosScroll setContentSize: CGSizeMake(1240, 200)]; 
// Add it as a subview to the mainView
[mainView addSubview:photosScroll];


// Set the photoScroll's delegate: 
photosScroll.delegate = self;

// Create a frame to which to scroll:   
CGRect frame = CGRectMake(10, 10, 80, 150);
// Scroll to that frame:
[photosScroll scrollRectToVisible: frame animated:YES];

So the scrollView loads successfully and I’m able to scroll it left and right with my finger – but it doesn’t do this “auto-scroll” like I was hoping it would.

  • I tried calling the scrollRectToVisible before and after adding the
    scrollView as a subview – didn’t work.
  • Thinking maybe this should
    happen in loadView and not in viewDidLoad? But if so, how?

Any ideas?

  • 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-26T14:26:09+00:00Added an answer on May 26, 2026 at 2:26 pm

    A couple of ways to do this:

    1. Use scrollRectToVisible:animated: for a zero X value and then a largeish positive one, then set it back to your middle point. You can call the method after the scroll view is added as a subview (probably before too, but best be safe). You’ll need to calculate what value of X is off-screen to the left using your contentSize and knowledge about how wide your various elements inside the scroll view are.
    2. Since you’re just doing a quick animation and will give the user control, this can really be a quick-and-dirty animation, so you could use setContentOffset:animated: to force the content of the scrollview to move relative to your current view position. Move the elements right for a left scroll (positive X value), then left twice as far for a right scroll (negative X value), then set the offset back to zero.

    You shouldn’t put either of these in viewDidLoad or loadView; put them in viewDidAppear, which is after your scrollview is actually drawn on screen. You only care about animations when the user can see them!

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

Sidebar

Related Questions

I have a UIScrollView that shows vertical data, but where the horizontal component is
I have a UIScrollView that contains a UITextView (not editable). I can't make the
I want to have horizontal lists that can run as wide as possible but
I have a custom-drawn view that I include in a UIScrollView that scrolls horizontally.
I just saw local mind's app and they have a horizontal UIScrollView that has
I'm trying to create a paginated UIScrollView within a view that only scrolls horizontally
I have a UIScrollView with only horizontal scrolling allowed, and I would like to
I have a UIScrollView that contains multiple UITableViews horizontally - all of which are
Do you know any controls inherited from the ItemsControl that have horizontal orientation of
i have a that contains a HORIZONTAL menu. the menu consists of an unordered

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.