我有UIButton
的子类在init方法中我将目标添加到按钮
[self addTarget:self action:@selector(openList:) forControlEvents:UIControlEventTouchUpInside];
在openList中
[listPopOver presentPopoverFromRect:self.frame
inView:self.superview
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
但在presentPopoverFromRect(EXC_BAD_ACCESS
)
答案 0 :(得分:2)
错误:
UIPopoverController* pop = [[UIPopoverController alloc] initWithContentViewController:[[UIViewController alloc] init]];
[pop presentPopoverFromRect:[tableView cellForRowAtIndexPath:indexPath].frame inView:tableView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
没有错误:
@property (strong, nonatomic) UIPopoverController* pop;
@synthesize pop = _pop;
pop = [[UIPopoverController alloc] initWithContentViewController:[[UIViewController alloc] init]];
[pop presentPopoverFromRect:[tableView cellForRowAtIndexPath:indexPath].frame inView:tableView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
答案 1 :(得分:2)
启用NSZombie
以检查哪个确切的实例正在创建问题,表格视图中似乎存在一些问题。
答案 2 :(得分:0)
if(![listPopOver isPopoverVisible]){
listPopOver = [[listPopOverViewController alloc] initWithNibName:@"listPopOverViewController" bundle:nil];
listPopOver.viewDelegate=self;
listPopOver = [[[UIPopoverController alloc] initWithContentViewController:PopOver] retain];
[listPopOver setPopoverContentSize:CGSizeMake(670.0f, 380.0f)];
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[listPopOver presentPopoverFromRect:CGRectMake(50, 160, 670, 380) inView:self.view permittedArrowDirections:0
animated:YES];
}
else{
[listPopOver dismissPopoverAnimated:YES];
}