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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:53:48+00:00 2026-06-15T10:53:48+00:00

Is it possible to pop up an UIViewController (xib file) like UIPopOverControl in iPad

  • 0

Is it possible to pop up an UIViewController (xib file) like UIPopOverControl in iPad ?

I have a separate NIB file which is linked to an UIViewController. I want to popup that NIB file along with the button pressed with a customised size (200,200).

Is this possible?

I am trying to get something like this on the iPhone – http://www.freeimagehosting.net/c219p

  • 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-15T10:53:49+00:00Added an answer on June 15, 2026 at 10:53 am

    yes it is. load Your pOpOver controller lazily at the point when it is needed. add its view as a subview (you could animate the addition). make its frame size what You need and add the image You have shown as a background subview of the pOpOver controller along with other controls You want in the pop up.

    good luck

    UPDATE:

    alright, ii will show You how ii do this in my app Lucid Reality Check (deployment target iOS4.3).

    one can use a UIPopoverController to present another controllers view. what ii do first is to make sure ii always know the current orientation of the device, so ii can reposition the popup on rotation (maybe this works by itself on iOS6?). so in my base controller (from where ii want to show a popup) ii have an instance variable like this:

      UIInterfaceOrientation toOrientation;
    

    and also:

      UIPopoverController *popover;
      UIButton            *popover_from_button;
      BOOL                 representPopover;
    

    popover will be reused for all popups, and popover_from_button will hold the button from which the popup is initiated.

    then the next code comes into the base controller:

    - (void)popoverWillRotate {
      if ([popover isPopoverVisible]) {
          [self dismissPopover];
          representPopover = YES;
      }
    }
    
    - (void)popoverDidRotate {
      if (popover && representPopover) {
          representPopover = NO;
          [self representPopover];
      }
    }
    

    these two methods have to be called every time the device is rotated, like this:

    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
      //DLOG(@"willRotateTo %i", toInterfaceOrientation);
      toOrientation = toInterfaceOrientation;
          if ([Kriya isPad ]) {
              [self popoverWillRotate];
          }
    }
    

    as one can see, first the orientation is captured then popoverWillRotate is called. this would hide the popover during the orientation animation. and after rotating, the popover must be redisplayed like this:

    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
            //DLOG(@"didRotateFrom %i", fromInterfaceOrientation);
        //[self layout:toOrientation]; //do some layout if You need 
        if ([Kriya isPad]) {
            [self popoverDidRotate];
        }
    }
    
    - (void)layout:(UIInterfaceOrientation)toInterfaceOrientation {
        //one can do view layout here, and call other controllers to do their layout too
    }
    

    now that the orientation changes are worked out, the code for presenting the popover arrives here:

    #pragma mark Popovers
    - (void)presentPopoverWith:(id)controller fromButton:(UIButton*)button {
        if (popover)
           [popover release];
        if (popover_from_button)
            [popover_from_button release];
        popover_from_button = [button retain];
        popover = [[UIPopoverController alloc] initWithContentViewController:controller];
        [popover setDelegate:self];
        [self representPopover];
    }
    
    - (void)representPopover{
        if (popover) {
            UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirectionAny;
            UIViewController *vc = (UIViewController*)[popover contentViewController];
            CGSize contentSize = [vc contentSizeForViewInPopover];
    
            if (contentSize.width > 0 && contentSize.height > 0) {
                [popover setPopoverContentSize:contentSize animated:NO];
            }
            //DLOG(@"representPopover rect:%@", [Kriya printRect:popover_from_button.frame]);
            [popover presentPopoverFromRect:CGRectOffset(popover_from_button.frame, 0, popover_from_button.frame.size.height + 7.0)  inView:self.view permittedArrowDirections:arrowDirection animated:YES];   
        }
    }
    
    - (void)dismissPopover {
        if (popover) {
            [popover dismissPopoverAnimated:YES];
       }
    }
    

    finally, if one wants to be notified when the popover is dismissed, the base controller must implement a delegate method:

    #pragma mark UIPopoverControllerDelegate
    - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
        //do something important here like drink some water
    }
    

    and don’t forget to make the base controller a UIPopoverControllerDelegate in its header.

    a use case for this way of doing popups would then look like this:

    - (void)takeImage {    
        UIImagePickerController *picker = [[[UIImagePickerController alloc] init] autorelease];
        [picker setDelegate:self];
        [picker setAllowsEditing:NO];
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            [picker setSourceType:UIImagePickerControllerSourceTypeCamera];         
            if ([Kriya isPad]) {            
                [self presentPopoverWith:picker fromButton:backgroundImageButton];
            } else {
                //modals on iPhone/iPod
                //DLOG(@"takeImage addSubview picker");
                [self presentModalViewController:picker animated:YES];
            }
        } else {
            //DLOG(@"no camera");
        }
    }
    

    this would use an image picker as the content for the popup, but one can use any controller with a valid view. so just do this:

    [self presentPopoverWith:popupsContentController fromButton:tappedButton];

    one should not have any missing information, :), the method [Kriya isPad] is just this:

    + (BOOL)isPad {
      #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
        // iPad capable OS
            if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
                //this is an iPad
                return YES;
            }else {
                //this is an iPod/iPhone
                return NO;
            }
      #else
          //can not pissible be iPad
              return NO;
      #endif
      }
    

    ENJOY!

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

Sidebar

Related Questions

Possible Duplicate: How to display temporary popup message on iPhone/iPad/iOS I want to be
Is it possible to pop more than one viewcontroller in UINavigationController? suppose i want
I wonder if it's possible to show a warning or open a pop-up, which
Does anybody know if it's possible to open a pop-up form Input Mask which
Is it possible with IASK to have a PSMultiValueSpecifier automatically pop the stack when
i have an pop.html which contains a <div> . can i use jquery to
Is it possible to have an overlay pop up upon tapping the screen, during
Possible Duplicate: How to compare two dates in Objective-C I'd like to pop up
Is it possible to have a button open a pop-up window that on page
Is it possible to pop the navigation controller twice? I have this navigation structure:

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.