2012-02-06 4 views
2

Я хочу предоставить событие IBIBE для пользовательских сотовых ячеек.Как передать событие IBAction пользовательскому сотовому UIButton?

Я пробовал с кодом ниже, но он падает.

Как создать делегат & использовать это в моем классе UITableView?

Customcell class

-(IBAction)btnShowAttachmentClick:(UITableView *)aTblViewCommon 
{ 
    [(ShowTechAndProfDetailsVC *)aTblViewCommon.delegate performSelector:@selector(showAttachmentsFromCell:) withObject:nil]; 
} 

UIViewController class having UITableView

-(void)showAttachmentsFromCell:(UIButton *)sender 
{ 
    gotoClass *obj = [[gotoClass alloc] initWithNibName:@"gotoClass" bundle:nil]; 
    [self.navigationController pushViewController:obj animated:YES]; 
    [obj release]; 
} 

Вот cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if(appDelegate.intCountSwipeForView == 1 || appDelegate.intCountSwipeForView == 2) 
    { 
     objCellView = [ViewExpAndEduCustomCell dequeOrCreateInTable:tableView]; 

     objCellView.selectionStyle = UITableViewCellSelectionStyleNone; 
     //objCellView.btnPaperClip.tag = indexPath.row; 
     [objCellView.btnPaperClip addTarget:self action:@selector(showAttachmentsFromCell:) forControlEvents:UIControlEventTouchUpInside]; 


     objCellView.lblName.text = @"asdfsdf"; 
     objCellView.lblTitleOrCourse.text = @"asdf"; 
     objCellView.lblStartDate.text = @"23-Nov-2001"; 
     objCellView.lblEndDate.text = @"04-Feb-2002"; 


     [objCellView.txtViewSummary setTextColor:TEXT_COLOR_GRAY_FOR_TABLECELL]; 
     [objCellView.txtViewSummary setFont:[UIFont systemFontOfSize:17.0]]; 
     [objCellView.txtViewSummary setContentInset:UIEdgeInsetsMake(-5, 0, 0, 0)]; 
     [objCellView.txtViewSummary setBackgroundColor:[UIColor clearColor]]; 
     [objCellView.txtViewSummary setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; 
    } 
if(appDelegate.intCountSwipeForView == 1){ 
     objCellView.txtViewSummary.text = @"Experience.This is sample text.This text can be of 150 characters.No more than that.You can also attach your achievment but only pdf,Image or video"; 
     return objCellView; 
} 
+0

показать код, где вы вызываете method..in TableView – Sarah

+0

Я не призываю в tableview.I просто позвонить в performselector из tableviewcell класса – Heena

+0

Вы пробовали это с аксессуар зрения Tableview с UIButton? –

ответ

1

эй иметь IBOutlet из вас кнопки в Customcell классе, то в

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    //creating cell or resusing cell 

    //after getting the cell and casting it into your Customcell 
     [cell.mButton addTarget:self action:@selector(showAttachmentsFromCell:) forControlEvents:UIControlEventTouchUpInside]; 

} 
+0

попытался, но не работает – Heena

+0

что не работает ??? –

+0

Не происходит внутри метода – Heena