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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:44:55+00:00 2026-05-26T22:44:55+00:00

Using Xcode 4.2/iOS5.0 I have a viewController and an associated viewController.xib. The viewController is

  • 0

Using Xcode 4.2/iOS5.0

I have a viewController and an associated viewController.xib. The viewController is set up as the .xib’s file’s owner. It is invoked from a UINavigationController.

I am attempting some manual layout when the device is rotated portrait/landscape

As I understand it the UIView method to override is

- (void)layoutSubviews;

this is where you do the layout

But – as with drawRect – you do not call this directly, it is invoked when appropriate by iOS

Instead you call setNeedsLayout…

So I have this in the ViewController

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)
         fromInterfaceOrientation {
   [[self view] setNeedsLayout];
 }

and in the same ViewController I have this

- (void)layoutSubviews {
    //.manual override of automatic layout on rotation
NSLog(@"layoutSubviews");
 }

However layoutSubviews does not get called and I don’t understand why.

Here is a clue…
If I call layoutSubviews directly as [self layoutSubviews]

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)
         fromInterfaceOrientation {
   [self layoutSubviews];
 }

it does trigger

But if I call it as [[self view] layoutSubviews] it does not

So it appears that the view and it’s controller are not wired up correctly?

  • 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-26T22:44:55+00:00Added an answer on May 26, 2026 at 10:44 pm

    Your problem here is you’ve implemented -layoutSubviews on your view controller, instead of on your view. It will never be called this way. -layoutSubviews is a mechanism by which a custom view can lay out its own subviews (e.g. a UIButton that has a UIImageView for the image and a UILabel for the label, and uses -layoutSubviews to ensure the imageview and label are all positioned correctly). It’s not a mechanism by which a view controller can control the layout of its views.

    If you want to change layout on rotation, then you should just go ahead and set up the new layout inside of -didRotateFromInterfaceOrientation:.

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

Sidebar

Related Questions

I'm working on some project for iOS 5 using Xcode 4.2. I have one
using xcode 4.2 and iOS 5 and have nav bar on root controller and
I've been using Xcode 3.x but today (nov 1st 2011) have downloaded Xcode 4.2
I am developing an app for iPhone using iOS5 and xcode 4.2. The scenario
I dont know but since using iOS5 (now 5.1) and Xcode 4 (now 4.3)
I am using Xcode 4.3 and iOS 5.1. I have add three20 to my
I was trying to work on xcode and ios5 and I have a TWRequest
Using Xcode 3.1 on OSX 10.5; is it possible to attach (the debugger) to
I've been using Xcode for the usual C/C++/ObjC development. I'm wondering what are practical
I am using xcode 2.4.1 on tiger. When i do below everything is ok.

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.