IOS iOS8 new Features--uipopoverpresentationcontroller

Source: Internet
Author: User

1. Review the use of Uipopovercontroller, the following code can only be run under the ipad

Initialize controller, Secondviewcontroller class inherits from Uiviewcontroller

Secondviewcontroller *VC = [[Secondviewcontroller alloc] init];

To package VC into Uipopovercontroller

Uipopovercontroller *popover = [[Uipopovercontroller alloc] INITWITHCONTENTVIEWCONTROLLER:VC];

Set the point of the PopOver,

Point to the current control button, so fromrect followed by bounds

If the view is pointing to the current control, the Fromrect is followed by the frame

[PopOver presentPopoverFromRect:self.button.bounds InView:self.button permittedarrowdirections: Uipopoverarrowdirectionany Animated:yes];

2. Using Uipopoverpresentationcontroller, the following code in the iphone and the ipad can be normal operation 2.1 in the iphone is a common modal way, that is, from the bottom of the screen to climb up,and on the ipad, it'spopover that way.

Initializing the Controller

Secondviewcontroller *VC = [[Secondviewcontroller alloc] init];

Modal out is a popover.

Vc.modalpresentationstyle = Uimodalpresentationpopover;

//Remove VC's Uipopoverpresentationcontroller

Vc.popoverPresentationController.sourceView = Self.button;

Vc.popoverPresentationController.sourceRect = Self.button.bounds;

[Self PRESENTVIEWCONTROLLER:VC animated:yes completion:nil];

2.2 In the iphone, the above code is equivalent to the following:

Secondviewcontroller *VC = [[Secondviewcontroller alloc] init];

/* Equivalent to 3 lines of code not present in the middle

Vc.modalpresentationstyle = Uimodalpresentationpopover;

Vc.popoverPresentationController.sourceView = Self.button;

Vc.popoverPresentationController.sourceRect = Self.button.bounds;

*/

[Self PRESENTVIEWCONTROLLER:VC animated:yes completion:nil];

2.3 Apple has extended the class to Uiviewcontroller in IOS8

Which means that Popoverpresentationcontroller is the Uiviewcontroller property.

Modalpresentationstyle is a uiviewcontroller member variable

Uipopoverpresentationcontroller inherit from Uipresentationcontroller, Uipresentationcontroller and inherit from NSObject

IOS iOS8 new Features--uipopoverpresentationcontroller

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.