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