IPad Control Uipopovercontroller Use

Source: Internet
Author: User

Uipopovercontroller is an ipad-specific control, (ios7-9), not obsolete after iOS9

Use steps
    • Setting up Content Controllers
      • Uipopovercontroller directly inherits the NSObject and does not have the ability of visualization. So be sure to specify a "content controller" that inherits from Uiviewcontroller to provide content
    • Set the size of the content
      • The size displayed on the screen
    • Show it from that place.
Code
    • Create a new VC class Menuviewcontroller as the uipopovercontroller content Controller,
    • In HOMEVC Add an attribute @property (nonatomic, strong) Uipopovercontroller *popover;
- (void) Poppopview {//Setting up Content controllersMenuviewcontroller *MENUVC =[[Menuviewcontroller alloc] init]; Self.popover=[[Uipopovercontroller alloc] INITWITHCONTENTVIEWCONTROLLER:MENUVC]; //set the size of the content if the preferredcontentsize size is set in the content controller self.preferredcontentsize = Cgsizemake (200, 200); then Self.popOver.popov Ercontentsize will be meaningless, and it should be controlled by the content controller in actual development.Self.popOver.popoverContentSize = Cgsizemake ( -, -); //from that place. The first argument is where the popover appears, and the second argument is the arrow direction[Self.popover PresentPopoverFromBarButtonItem:self.navigationItem.leftBarButtonItem permittedarrowdirections        : Uipopoverarrowdirectionany Animated:yes]; //This method is a custom occurrence of the location of the Rect: arrow points to the area range, with the upper left corner of the view as the coordinate Origin//[Self.popover presentpopoverfromrect:cgrectmake (getwindowwidth * 0.5, 0, 0) InView:self.view Permittedarrowdi Rections:uipopoverarrowdirectionup Animated:yes];}

Note: If the preferredcontentsize size is set in the content controller self.preferredcontentsize = Cgsizemake (200, 200); Then self.popOver.popoverContentSize will be meaningless, and the content controller should control the size in real development
Menuvc
    • -(void) Viewdidload {
      [Super Viewdidload];
      Self.view.backgroundColor = [Uicolor Redcolor];
      Self.preferredcontentsize = Cgsizemake (200, 200);
      }

  

    • Set up Proxy
      • Set up Proxy
        Self.popOver.delegate = self;
      • #pragma mark-Proxy method
        Call when Popovercontroller disappears.
        -(void) Popovercontrollerdiddismisspopover: (Uipopovercontroller *) Popovercontroller {

        }
        Popovercontroller when the position of the change is changed (such as vertical screen to change the horizontal screen)
        -(void) Popovercontroller: (Uipopovercontroller *) Popovercontroller willrepositionpopovertorect: (inout CGRect *) rect InView: (inout UIView *__autoreleasing *) View {

        }
        Used to determine if the user clicked on the mask, Popovercontroller can dismiss, return yes to represent can, return no represents not can
        -(BOOL) Popovercontrollershoulddismisspopover: (Uipopovercontroller *) Popovercontroller {
        return NO;
        }
 
    • Mask Attention Point
    • By default, as long as Uipopovercontroller is displayed on the screen, all the controls behind Uipopovercontroller are not able to interact with the user normally, click Controls outside the Uipopovercontroller area. Uipopovercontroller will disappear by default
      To not let Uipopovercontroller disappear when you click a control outside the Uipopovercontroller area, the workaround is to set the Passthroughviews property
      Setting those controls can be done interactively
    • Self.popOver.passthroughViews = @[self.test11]; You can see that the test11 button can interact

  

IPad Control Uipopovercontroller Use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.