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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:31:45+00:00 2026-05-18T00:31:45+00:00

I am trying to create a game on the iPhone, however I am running

  • 0

I am trying to create a game on the iPhone, however I am running in to some (I hope) simple, yet confusing issues.

I am forcing my application to be in UIInterfaceOrientationLandscapeRight mode, this is set in the .plist and each of my UIViewControllers returns this as the only viable orientation for shouldAutorotateToInterfaceOrientation

That works… sometimes. Each of my xibs have been designed to be in landscape mode, and all ViewControllers are set up in a very similar fashion. Here is my problem:

I instantiate all of my UIViewControllers programatically such as:

splashScreen = [[SplashScreenController alloc] initWithNibName:@"SplashScreenView" bundle:[NSBundle mainBundle]];
splashScreen.view.frame = CGRectMake(0, 0, [[GameConsts defaultGameConsts] screenWidth], [[GameConsts defaultGameConsts] screenHeight]);
[[self view] addSubview: [splashScreen view]];

mainMenu = [[MainMenuController alloc] initWithNibName:@”MainMenuView” bundle:[NSBundle mainBundle]];
mainMenu.view.frame = CGRectMake(0, 0, [[GameConsts defaultGameConsts] screenWidth], [[GameConsts defaultGameConsts] screenHeight]);
[[self view] addSubview: [mainMenu view]];

This works fine, but when I activate my “game views”, i.e., the in-game menus and actual playing field I need to invert the screenWidth and screenHeight parameters to get them to be correctly displayed. I do not understand why this is, and I have not yet been able to figure it out. Here is how they are being instantiated:

- (void) setupGameViews
{
 // Why do these need to be reversed to show up properly? (Height and Width!)
 gameView = [[GameController alloc] initWithNibName:@"GameView" bundle:[NSBundle mainBundle]];
 gameView.view.frame = CGRectMake(0, 0, [[GameConsts defaultGameConsts] screenHeight], [[GameConsts defaultGameConsts] screenWidth]);
 [[self view] addSubview: [gameView view]];

 gameMenu = [[GameMenuController alloc] initWithNibName:@"GameMenuView" bundle:[NSBundle mainBundle]];
 gameMenu.view.frame = CGRectMake(0, 0, [[GameConsts defaultGameConsts] screenHeight], [[GameConsts defaultGameConsts] screenWidth]);
 [[self view] addSubview: [gameMenu view]];
}

(Note: This method is being called when a start game button is clicked. This is all inside a “parent” UIViewController that has no associated view with it, but instead contains and sets up all of these subviews. Maybe there is an issue with their architecture? I have seen some similar examples around, so I decided to use it.)

For completeness, here are the definitions in the GameConsts singleton during its init method:

- (id) init
{
 screenWidth = [[UIScreen mainScreen] applicationFrame].size.width;
 screenHeight = [[UIScreen mainScreen] applicationFrame].size.height;

 screenCenter = CGPointMake(screenSizeHeight / 2, screenSizeWidth / 2);

 return [super init];
}

screenWidth and screenHeight are floats. screenCenter is a CGPoint. If you note, I have reversed the height/width in the screenCenter CGPoint because otherwise when I try to draw an object at the screen center it shows up in the bottom left corner of the screen.

This is driving me crazy and keeping me from the far more fun parts of this experience. If anyone can provide help, it would be wonderful. If any more information is needed, let me know.

  • 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-18T00:31:46+00:00Added an answer on May 18, 2026 at 12:31 am

    I think that applicationFrame always returns a frame for portrait orientation.

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

Sidebar

Related Questions

I am trying to create a cool score counter in my iPhone game, where
I am currently trying to create a menu system for a game and cannot
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create my first iPhone app that would play back audio. When I
Trying to create a small monitor application that displays current internet usage as percentage
Trying to create a list to return some JSON data to a view. Following
I am trying to implement a game using the iPhone OS 4.0 (iOS4?) SDK.
I am trying to create a custom Application template. I tried to learn, How
I am developing an iPhone app and would like to create some sort of
I am trying to create a tic - tac - toe type of game

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.