Closing a popover with a button (within another .xib file)

Discussion in 'iPhone/iPad Programming' started by BarryK88, May 19, 2011.

  1. macrumors member

    Joined:
    Mar 1, 2011
    #1
    I've got a popover within my view. Within this popover there is content from another xib file (Infoscreen.xib). How can I dismiss the popover with a button which is inside another .xib file? Here's a snippit of my code:

    Code:
    -(IBAction)infoDruk: (id)sender {
    
        if([popover isPopoverVisible]) {
            [popover dismissPopoverAnimated:YES];
    
        }
        else {
    
            Infoscreen *choser =  [[Infoscreen alloc] init];
            popover = [[UIPopoverController alloc]
                       initWithContentViewController:choser];
            [choser release];
            popover.delegate = self;
            popover.popoverContentSize = CGSizeMake(230, 563);
            [popover presentPopoverFromBarButtonItem:sender
                            permittedArrowDirections:UIPopoverArrowDirectionAny
                                            animated:YES];
        } 
    }
    Help is greatly appreciated!
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    There doesn't seem to be a "popoverController" property in UIViewController which is a shame. So create on in Infoscreen and set it in the method you have posted. This will give methods in your Infoscreen instance access to the UIPopoverController instance.
     

Share This Page