(1) Uipopovercontroller is the ipad-specific frame-like class, it does not have a view, because it inherits directly from NSObject, so you need to set up the content controller when initializing. As follows:
-(Uipopovercontroller *) titlepop{ if (_titlepop==nil) { Uitableviewcontroller *tablevc=[[ Uitableviewcontroller Alloc]init]; _titlepop=[[uipopovercontroller ALLOC]INITWITHCONTENTVIEWCONTROLLER:TABLEVC]; } return _titlepop;}
(2) There are 2 ways of using Uipopovercontroller, one is around Barbuttonitem, one is around rect, and of course the scope of RECT is very wide. As follows:
-(void) Menuclick: (Uibarbuttonitem *) sender{ //directly around Barbuttonitem [self.menupop Presentpopoverfrombarbuttonitem:sender permittedarrowdirections:uipopoverarrowdirectionany Animated:YES];} -(void) Titleclick: (UIButton *) btn{ //Note the relationship between Rect and InView [Self.titlepop presentPopoverFromRect:btn.frame InView:btn.superview Permittedarrowdirections:uipopoverarrowdirectionany Animated:yes]; [Self.titlepop presentPopoverFromRect:btn.bounds inview:btn Permittedarrowdirections:uipopoverarrowdirectionany Animated:yes];}
(3) Uipopovercontroller also has some other properties, such as whether it is visible or not.
There are also the following methods. Set content View Controller//[self.menupop Setcontentviewcontroller:nav Animated:yes]; Set PopOver size//[self.menupop setpopovercontentsize:cgsizemake (+)];//self.menupop.popovercontentsize= Cgsizemake (+); When setting the click, PopOver does not disappear (by default, click anywhere outside the popover disappears)//[self.menupop Setpassthroughviews:@[self.btn]];//[email protected][ SELF.BTN];
Of course, the most practical is the one above the size of the property, but if the size needs to be set in the content view controller? Can not be practical setpopovercontentsize, need to use the following properties:
Self.preferredcontentsize=cgsizemake (100, 100);
(4) Solution:-[uipopovercontroller Dealloc] reached while popover is still visible.
Cause: The PopOver controller created is a local variable, and a curly brace is executed {} to destroy it, so there is a problem.
Workaround: Change the local variable to a global variable. It is defined as follows, and then used with Self.hellopop:
@interface Viewcontroller () @property (Nonatomic,strong) Uipopovercontroller *hellopop; @end
Note: This error is no longer present in iOS8, which is just a local variable defined in curly braces, but not an error. This error is generally in iOS7 and the following systems.
"iOS Dev-106" Uipopovercontroller,[uipopovercontroller Dealloc] reached while popover is still visible