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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:46:20+00:00 2026-05-20T17:46:20+00:00

UIScrollView Based Image gallery getting white gap at the top of the image ,

  • 0

UIScrollView Based Image gallery getting white gap at the top of the image , the image gets pushed down a bit . How can I remove the white space ?

@implementation PagerViewController

- (void) setImages:(NSArray *) images
{
    if(imageSet) [imageSet release];

    imageSet = [images retain];

    view1.frame = CGRectMake(0,0,320,480);
    view2.frame = CGRectMake(320,0,320,480);

    view1.image = [imageSet objectAtIndex:0];
    view2.image = [imageSet objectAtIndex:1];

    scroll.contentSize = CGSizeMake([imageSet count]*320,480);
}

- (id) init
{
    if(self = [super init])
    {
        scroll = [[UIScrollView alloc] init];
        scroll.scrollEnabled = YES;
        scroll.pagingEnabled = YES;
        scroll.directionalLockEnabled = YES;
        scroll.showsVerticalScrollIndicator = NO;
        scroll.showsHorizontalScrollIndicator = NO;
        scroll.delegate = self;
        scroll.backgroundColor = [UIColor clearColor];
        scroll.autoresizesSubviews = YES;
        scroll.frame = CGRectMake(0,0,320,480);
        [self.view addSubview:scroll];

        view1 = [[UIImageView alloc] init];
        [scroll addSubview:view1];

        view2 = [[UIImageView alloc] init];
        [scroll addSubview:view2];
    }

    return self;
}

- (void) update
{
    CGFloat pageWidth =320;
    float currPos = scroll.contentOffset.x;

    int selectedPage = roundf(currPos / pageWidth);

    float truePosition = selectedPage*pageWidth;

    int zone = selectedPage % 2;

    BOOL view1Active = zone == 0;

    UIImageView *nextView = view1Active ? view2 : view1;

    int nextpage = truePosition > currPos ? selectedPage-1 : selectedPage+1;

    if(nextpage >= 0 && nextpage < [imageSet count])
    {
        if((view1Active && nextpage == view1Index) || (!view1Active && nextpage == view2Index)) return;

        NSLog(@"Load next image!");

        nextView.frame = CGRectMake(nextpage*320,0,320,480);
        nextView.image = [imageSet objectAtIndex:nextpage];

        if(view1Active) view1Index = nextpage;
        else view2Index = nextpage;
    }
}
  • 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-20T17:46:21+00:00Added an answer on May 20, 2026 at 5:46 pm

    Edited in the .plist file ” Status Bar Initially Hidden – Checked ” Solved it !

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

Sidebar

Related Questions

I have 6 UITextFields on my UIScrollView . Now, I can scroll by user
can you help me setting up a delegate for a UIScrollView, so I can
I have a UIImageView in a UIScrollView in another UIScrollView (based on Apple's PhotoScroller
I have a UIScrollView that shows vertical data, but where the horizontal component is
I use UIScrollView to make large-sized (larger than 320px) UI on iPhone. I made
I'm displaying a series of images in a UIScrollView. I pretty much want to
I have a Graph being drawn inside a UIScrollView . It's one large UIView
I have a subclass of UIScrollView that overrides touchesBegan:withEvent: touchesMoved:withEvent: touchesEnded:withEvent: Overriding these three
I'm building a navigation controller based iPhone application and am curious how to go
I want to add UIControls to a UIScrollView, eg. UIControl *couponView = [[UIControl alloc]

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.