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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:23:05+00:00 2026-05-28T07:23:05+00:00

I have a UIPopoverController with two view controllers inside of it. I’m building it

  • 0

I have a UIPopoverController with two view controllers inside of it. I’m building it like so:

CommentsPopoverController *commentsPopoverController = [[CommentsPopoverController alloc] init];
self.delegate = commentsPopoverController;
commentsPopoverController.navigationItem.title = @"Comments";
UINavigationController *navController = [[UINavigationController alloc]                               initWithRootViewController:commentsPopoverController];
popover = [[UIPopoverController alloc] initWithContentViewController:navController];

Inside my commentsPopoverController I have this:

commentsViewController = [[CommentsViewController alloc] init];
commentsViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

addCommentsViewController = [[AddCommentViewController alloc] init];
addCommentsViewController.view.frame = CGRectMake(0, commentsViewController.view.bounds.size.height - 200, 320, 346);
addCommentsViewController.view.backgroundColor = [UIColor darkGrayColor];

[self.view addSubview:addCommentsViewController.view];
[self.view addSubview:commentsViewController.view];

So when I first load the popover, the addCommentsViewController is hidden by the commentsViewController. When I reveal it, it looks like this:

popover with both controllers visible

So far so good. The problem I’m having is that from here, when the user rotates the device or shows the keyboard or shows the keyboard THEN rotates the device things start to get out of whack. The top view controller (commentsViewController) which is a UITableView always does the right thing no matter what the orientation is or whether or not the keyboard is showing. But the bottom view controller (addCommentsViewController) doesn’t automatically change it’s origin.y to stay directly under the top view controller.

So I’ve basically had to hack the crap out of my code to keep the addCommentsViewController directly under the commentsViewController by constantly calculating the height of the top view controller so that I could adjust the bottom view controller’s origin.y. This involved dropping in NSNotifications for the keyboard’s show/hide state and for the device’s orientation and constantly recalculating. Very hackish and ugly.

So my question (finally) is: Is there an easier way of controlling these views or am I stuck hacking it the way I did?

  • 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-28T07:23:06+00:00Added an answer on May 28, 2026 at 7:23 am

    To handle rotation, there are two appropriate techniques. One is that you make CommentsPopoverController‘s view a subclass of UIView that overrides layoutSubviews to lay out your two views properly. The other is that you define viewDidLayoutSubviews on CommentsPopoverController to lay out your views. If you lay out your views in either of these methods, you shouldn’t have to subscribe to rotation notifications.

    As for moving your view out from under the keyboard, that is discussed in the Text, Web, and Editing Programming Guide for iOS. Part of the technique involves subscribing to keyboard will show/did hide notifications.

    I assume your CommentsViewController is a subclass of UITableViewController, because UITableViewController takes care of adjusting the table view when the keyboard is hidden or shown.

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

Sidebar

Related Questions

If I have a UIPopoverController (in .h file) and alloc init it multiple times
I have the following code: UIImagePickerController *imagePicker = [[UIImagePickerController alloc] initWithRootViewController:self]; imagePicker.delegate = self;
In my app i have two view controllers and have table view in both.Both
I have a UIPopOverController and this is my code: [myPopOver presentPopoverFromRect:CGRectMake(20,5, 325, 600) inView:self.view
I have a popover view which is called with: Info *infoview = [[Info alloc]init];
I have one delegate file, one View Controller and one UIPopoverController My PopoverController is
I have a UIPopoverController named popover in another view. What I would like to
I have my UIPopoverController with self as a delegate: I receive calls when I
I have a UIPopOverController that shows a UIViewController with a UITableview in its view.
I have a button inside the content of a UIPopoverController. This button runs 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.