我想弄清楚如何使用下面的方法而不是導致內存泄漏。 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你說得對,但是當我搜索時沒有出現。 –