-(void)showsearch:(id)sender
{
SearchViewController *searchview =[[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
settingpopoverController = [[[UIPopoverController alloc]
initWithContentViewController:searchview] autorelease];
[searchview release];
[settingpopoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
当我点击按钮时,应用程序崩溃了,我收到了[UIPopoverController dealloc] reached while popover is still visible.
消息。
答案 0 :(得分:6)
这里有关于这个主题的一些很好的讨论:
Retain/release pattern for UIPopoverController, UIActionSheet, and modal view controllers?
UIPopoverController and memory management
它的要点是你需要:
答案 1 :(得分:3)
认为autorelease不正确,这是一个教程
http://www.jannisnikoy.nl/index.php/2010/04/ipad-tutorial-creating-a-popoverviewcontroller
答案 2 :(得分:3)
问题是你正在设置
settingpopoverController =
当你的意思是
self.settingpopoverController =
自动释放是正确的。第二个使用属性访问器,第一个使用iVar。