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

  • Home
  • SEARCH
  • 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 7909723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:34:06+00:00 2026-06-03T12:34:06+00:00

Hello fellow programmers, First, sorry for the long post. My question is rather simple,

  • 0

Hello fellow programmers,

First, sorry for the long post. My question is rather simple, but I want to make sure you know what I’m doing and I really don’t want to change the basic idea of my approach.

(the following is all done programmatically, no storyboards, no nibs, no navigationcontroller)

I have a RootViewController without an own view. All he does is instantiate other ViewControllers, manage their transitions and push (add) their views into the main window. To position these views correctly, I want to get bounds/frame for one of the RootViewCOntrollers SubControllers. This is how I create the RootViewController from the appDelegate (I started with a empty project)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor grayColor];
    self.window.rootViewController = [[UCRootViewController alloc]init];
    [self.window makeKeyAndVisible];
    return YES;
}

After his initialization, the rootviewController creates a MapViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSLog(@"RootviewController initialized");
    self.mapviewController = [[UCMapviewController alloc] initWithDelegate:self];
    self.view = self.mapviewController.view;
    [self.mapviewController.view setOpaque:YES];
    [self.view bringSubviewToFront:self.mapviewController.view];
    [self presentModalViewController:self.mapviewController animated:YES];
    self.currentlyActiveController = self.mapviewController;
}

The MapViewController creates a navigationBar and a MKMapView. Right now I set the frames hardcoded, because I’m not able to get the bounds/frame of the window in the viewDidLoad() of the MapViewController When I try to get any infos about bounds/frame, I get 0 returned.

- (void)viewDidLoad
{
    NSLog(@"MapviewController initialized");
    [super viewDidLoad];

    self.isMapViewPushedAside = NO;
    // Custom initizialation for navigationBar
    [self setupNavigationBar];

    // Custom initialization for mapview
    [self setUpMapview];
    [self trackUserLocation];

    // Custom initialization for popupActionsButton
    [self setUpPopupButtons];

    // Custom tests
    [self test];

    [self focusLocationOnMap:self.locationManager.location.coordinate];
    [self.locationManager stopUpdatingLocation];
}

I’ve implemented two delegate methods that return frame/bounds (same) for the window. The problem is, I must get those values at the start, not after everything has been initialized. when I call the delegate methods from a button after everything is up, they work as expected.

CGRect frame = [self.mapDelegate frameData];
NSLog(@"width by frame: %f", frame.size.width);
NSLog(@"height by frame: %f", frame.size.height);

CGRect bounds = [self.mapDelegate boundsData];
NSLog(@"width by bounds: %f", bounds.size.width);
NSLog(@"height by bounds: %f", bounds.size.height);

How do I obtain the frame/bounds at the start, that is, before calling my custom “setup” methods..?!

  • 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-03T12:34:08+00:00Added an answer on June 3, 2026 at 12:34 pm

    I have a RootViewController without an own view.

    You can’t have a UIViewController without a view. If you have the app will crash. When you initialize a UIViewController it automatically creates a UIView for you.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        ..
        self.mapviewController = [[UCMapviewController alloc] initWithDelegate:self];
        self.view = self.mapviewController.view;
        ..
    }
    

    From what can I see here, you’re actually setting the RootviewController’s view to be the map view. This should be done by overriding the -(void)loadView method of your controller and there you need to set the view:

    -(void)loadView
    {
        self.mapviewController = [[UCMapviewController alloc] initWithDelegate:self]; //if you're not using ARC this should be autoreleased;
        self.view = self.mapviewController.view;
    }
    

    When viewDidLoad method is called there is no geometry set in any of the views of your controller. They are only initialized (implicitly or explicitly by -(void)loadView) and viewDidLoad is called just right after that. Geometry is setup at earliest in viewWillAppear: method and the consecutive viewDidAppear: method, so viewWillAppear: is the earliest point you can have your actual frame/bounds of your views and in viewWillAppear: method you should only execute some lightweight operations (like setting geometry, starting timers, subscribe observers, etc..).
    You said you don’t want to change your approach, but you need to design according to these rules.

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

Sidebar

Related Questions

Hello fellow developers... just to make sure, I want to ask this question: How
Hello fellow C++ programmers. I have, what I hope to be, a quick question
Hello fellow programmers, I am building a website and i read about sitemap.xml, but
Hello fellow programmers, I'm using nice URLs the first time and I can't quite
Hello fellow software developers. I want to distribute a C program which is scriptable
Hello fellow programmers, I have made a function that looks up the database if
Hello fellow programmers, got a few problem here. I am adding a user control
Hello fellow developers. First of all I apologize beforehand for the wall of text
Hello fellow programmers! Recently, I started learning Git, and pretty quickly discovered the amazing
Hello Again my fellow programmers out there, I'm designing and programming from scratch a

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.