2012-12-13 51 views
-1

當我從IB中的按鈕運行此操作時,該方法稱爲罰款。如果我從代碼中運行它與無法識別選擇的應用程序崩潰發送到實例錯誤當一個方法以編程方式調用,但在IB中工作時,應用程序崩潰

這裏的方法:

-(void)bottomCenter:(id)sender 
{ 
    [self popover:sender]; 
} 

-(void)popover:(id)sender 
{ 
    //the controller we want to present as a popover 
    DemoTableController *controller = [[DemoTableController alloc] initWithStyle:UITableViewStylePlain]; 
    controller.delegate = self; 
    popover = [[FPPopoverController alloc] initWithViewController:controller]; 

    //popover.arrowDirection = FPPopoverArrowDirectionAny; 
    popover.tint = FPPopoverDefaultTint; 

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    { 
     popover.contentSize = CGSizeMake(300, 500); 
    } 
    else { 
     popover.contentSize = CGSizeMake(200, 300); 
    } 

    popover.arrowDirection = FPPopoverArrowDirectionAny; 

    //sender is the UIButton view 
    [popover presentPopoverFromView:sender]; 
} 

,這是我如何把它從一個工具欄按鈕:

UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icons-footer-filter.png"] style:UIBarButtonItemStylePlain target:self action:@selector(bottomCenter:)]; 

我用target:self action:@selector(bottomCenter:)來錯誤地稱它嗎?

感謝

+0

你爲什麼不直接調用該方法酥料餅? bottomSender的目的是什麼? – johan

+0

調用bottomCenter方法沒有任何參數。刪除(id)發件人的東西,然後嘗試 –

+1

什麼是uncrecognized選擇器?它應該告訴你你試圖打電話的東西不存在。更仔細地看看錯誤消息 –

回答

相關問題