2012-07-03 155 views
1

我有子類的UIButton發生崩潰presentPopoverFromRect

在presentPopoverFromRect(EXC_BAD_ACCESS

init方法我在openList

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

添加的目標按鈕

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

但應用

enter image description here

+0

我認爲你需要改變 - self.view.superview而不是self.superview在presentPopoverFromRect方法 – rishi

+0

EXC_BAD_ACCESS意味着你期望的(有效的)不是。檢查self.superView – tagyro

+0

@rishi我也試過self.superview。 。 。 –

回答

2

啓用NSZombie以檢查它的確切實例創建問題,好像有在表視圖中的一些問題。

+1

是Rishi,我正在使用'@property(readwrite,assign)NSArray * listArray;'我改變了'assign'到'retain' –

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]; 
} 
+0

不適合我。 。但是,如果條件是 –

+0

請檢查 - 筆尖名稱是否正確? –

+0

感謝您的resposne,rishi評論解決了我的問題 –

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];