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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:30:49+00:00 2026-06-10T00:30:49+00:00

I am using this code to show scrolling images but I am only getting

  • 0

I am using this code to show scrolling images but I am only getting a white screen. I drag drop uiscrollview, created the iboutlet, synthesized it and rest of the code is here

@synthesize scrollView1;

const CGFloat kScrollObjHeight  = 199.0;
const CGFloat kScrollObjWidth   = 280.0;
const NSUInteger kNumImages     = 5;

- (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)];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    scrollView1 = [[UIScrollView alloc]init];

    bgArray = [NSArray arrayWithObjects:@"Bg", @"Bg1.png", @"Bg2.png", @"Bg3.png", @"Bg4.png", @"Bg5.png", @"Bg6.png", @"Bg7.png", @"Bg8.png", nil];

    [scrollView1 setBackgroundColor:[UIColor blackColor]];
    [scrollView1 setCanCancelContentTouches:NO];
    scrollView1.indicatorStyle = UIScrollViewIndicatorStyleWhite;
    scrollView1.clipsToBounds = YES;        // default is NO, we want to restrict drawing within our scrollview
    scrollView1.scrollEnabled = YES;

    // pagingEnabled property default is NO, if set the scroller will stop or snap at each photo
    // if you want free-flowing scroll, don't set this property.
    scrollView1.pagingEnabled = YES;

    // load all the images from our bundle and add them to the scroll view
    NSUInteger i;
    for (i = 0; i < [bgArray count]; i++)
    {
        NSString *imageName = [NSString stringWithFormat:@"%@", [bgArray objectAtIndex:i]];
        UIImage *image = [UIImage imageNamed:imageName];
        UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

        // setup each frame to a default height and width, it will be properly placed when we call "updateScrollList"
        CGRect rect = imageView.frame;
        rect.size.height = 199.0;
        rect.size.width = 280.0;
        imageView.frame = rect;
        imageView.tag = i;  // tag our images for later use when we place them in serial fashion
        [scrollView1 addSubview:imageView];
        [scrollView1 setShowsHorizontalScrollIndicator:NO];
        [scrollView1 setShowsVerticalScrollIndicator:NO];
    }

    [self layoutScrollImages];

}
  • 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-10T00:30:51+00:00Added an answer on June 10, 2026 at 12:30 am

    I think if you are create UIScrollView from code

    scrollView1 = [[UIScrollView alloc]init];
    

    then please add the scrollView1 in view
    Example:-[self.view addSubview:scrollView1];

    if you are create UIScrollView from nib then
    not use this code

    scrollView1 = [[UIScrollView alloc]init];
    

    solve your probem

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

Sidebar

Related Questions

Im using this code to show on screen some fancybox message: $.fancybox( { content:
Im using this code to show/hide a div: <a href=# class=show_hide>Show/hide</a> <div class=slidingDiv> My
I'm using this jquery code to show and hide divs on my page. As
After using this code to get my link to show me 3 database entrys
I'm currently using this code (per the codex) to show children on parent pages,
I am using this code in my website to show Google search results for
I am using this code to parse this date. It must show new date
I'm using this code for my web assignment: http://csstechniques.blogspot.sg/2007/05/super-simple-css-bars.html But how do I show
I have this code to show a map using the Virtual Earth API: <script
I am using this code to show latest user comments on my website -

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.