"iOS Dev-106" Uipopovercontroller,[uipopovercontroller Dealloc] reached while popover is still visible

Source: Internet
Author: User

(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

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.