我想弄清楚如何使用下面的方法而不是导致内存泄漏。 A UIPopoverController
已分配,但如果我包含autorelease
或release
调用,则应用程序崩溃,并显示消息'-[UIPopoverController dealloc] reached while popover is still visible.'
。这不是一个内存泄漏
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
[mapView deselectAnnotation:view.annotation animated:TRUE];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIViewController *con = [[UIViewController alloc] init];
UIPopoverController *poc = [[UIPopoverController alloc] initWithContentViewController:con];
[con release];
poc.popoverContentSize = CGSizeMake(320, 320);
[poc presentPopoverFromRect:view.bounds inView:view permittedArrowDirections:UIPopoverArrowDirectionAny animated:TRUE];
}
else {
; // TODO (miked): display stuff another way
}
}
这似乎违背了基本的内存管理实践。
p.s.我没有启用ARC。
的可能重复[保管好UIPopoverController,UIActionSheet和莫代尔/释放模式视图控制器?](http://stackoverflow.com/questions/2867709/retain-release-pattern-for-uipopovercontroller-uiactionsheet-and-modal-view-co) – StilesCrisis
好问题,但我认为这是由上面的链接回答。 – StilesCrisis
@StilesCrisis你说得对,但是当我搜索时没有出现。 –