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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:54:46+00:00 2026-05-27T18:54:46+00:00

This question discusses how to create gaps between views in a UIScrollView. The agreed

  • 0

This question discusses how to create gaps between views in a UIScrollView. The agreed method is to increase the width of UIScrollView’s frame to create gaps between the views which will be scrolled past. However when the scroll view is a subview of a UINavigationController an issue arises. The UINavigationController changes the frame of the UIScrollView after it has been set up in -viewDidLoad. The solution proposed is to alter the frame size in -viewDidAppear, at which point UINavigationController has finished changing things and the alterations will stick.

- (void)viewDidAppear:(BOOL)animated {
    CGRect frame = self.view.frame;
    frame.size.width += 20; // This gives a 20px gap width
    self.view.frame = frame;
}

I’ve been using this in my application and it has been working fine, but I run into problems when the app is sent to the background and then retrieved again. It seems that UINavigationController changes the frame once again, resetting it to the default width, but this time -viewDidAppear is not called and so the alteration is never made. I’ve tried registering for UIApplicationWillEnterForegroundNotification and UIApplicationDidBecomeActiveNotification but both of these seem to occur before UINavigationController changes things, so altering the frame at this point has no effect.

At what point should I try to change the frame size such that it will stick, or can I somehow prevent UINavigationController from altering the frame in the first place?

EDIT:

So I subclassed UIScrollView and found that a method called [UIViewControllerWrapperView setFrame:] is being called which is in turn calling my subclass’s -setFrame: method to set the frame size. I don’t know what UIViewControllerWrapperView is or does and I’m not sure it is going to be possible to jump in after it has done its thing and set the frame size properly. I will continue to investigate.

  • 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-27T18:54:46+00:00Added an answer on May 27, 2026 at 6:54 pm

    I solved this problem by making the UIScrollView a subview of my View Controller’s view. As a result, the UINavigationController leaves the UIScrollView alone and the frame is preserved. This also had the added benefit of allowing me to apply the padding in the same method I use to set up the scroll view, instead of later on in -viewDidLoad.

    So in summary, I’ve done this:

    CGRect frame = CGRectMake(0, 0, 320, 460);
    scrollView = [[UIScrollView alloc] initWithFrame:frame];
    
    // I do some things with frame here
    
    CGRect f = scrollView.frame;
    f.size.width += PADDING; // PADDING is defined as 20 elsewhere
    scrollView.frame = f;
    
    [self.view addSubview:scrollView];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question discusses encrypting data on the iPhone using the crypt() function. As an
This question has been discussed in two blog posts ( http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/ , http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/ ),
This question is kind of an add-on to this question In C#, a switch
This question and answer shows how to send a file as a byte array
This question comes on the heels of the question asked here . The email
This question would probably apply equally as well to other languages with C-like multi-line
This question is a follow up to my previous question about getting the HTML
(This question is over 6 years old and probably no longer has any relevance.)
This question is about removing sequences from an array, not duplicates in the strict
This question is the other side of the question asking, How do I calculate

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.