1

我有 UIButton 的子类

在 init 方法中,我将目标添加到按钮

[self addTarget:self action:@selector(openList:) forControlEvents:UIControlEventTouchUpInside];

在开放列表中

[listPopOver presentPopoverFromRect:self.frame
                          inView:self.superview
                          permittedArrowDirections:UIPopoverArrowDirectionUp
                          animated:YES];

但是在presentPopoverFromRect( EXC_BAD_ACCESS)上的应用

在此处输入图像描述

4

3 回答 3

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];
于 2012-07-03T12:49:32.573 回答
2

启用NSZombie以检查哪个确切的实例正在创建问题,表视图中似乎存在一些问题。

于 2012-07-03T14:32:27.193 回答
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];
}
于 2012-07-03T11:53:17.750 回答