单击单元格索引时tableview崩溃

时间:2014-09-28 17:19:11

标签: ios objective-c uitableview unrecognized-selector

当我点击单元格时它直接崩溃并且无法进入单元格didSelectRowAtIndexPath,并给出此错误

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIGestureDelayedTouch tableView:didSelectRowAtIndexPath:]: unrecognized selector sent to instance 0x1294e8b0'
*** First throw call stack:
(
    0   CoreFoundation                      0x041381e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x03eb38e5 objc_exception_throw + 44
    2   CoreFoundation                      0x041d5243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x0412850b ___forwarding___ + 1019
    4   CoreFoundation                      0x041280ee _CF_forwarding_prep_0 + 14
    5   UIKit                               0x02c5d9a1 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1513
    6   UIKit                               0x02c5db14 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 279
    7   UIKit                               0x02c6210e __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43
    8   UIKit                               0x02b910aa ___afterCACommitHandler_block_invoke + 15
    9   UIKit                               0x02b91055 _applyBlockToCFArrayCopiedToStack + 403
    10  UIKit                               0x02b90e76 _afterCACommitHandler + 532
    11  CoreFoundation                      0x0410036e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    12  CoreFoundation                      0x041002bf __CFRunLoopDoObservers + 399
    13  CoreFoundation                      0x040de254 __CFRunLoopRun + 1076
    14  CoreFoundation                      0x040dd9d3 CFRunLoopRunSpecific + 467
    15  CoreFoundation                      0x040dd7eb CFRunLoopRunInMode + 123
    16  GraphicsServices                    0x0480c5ee GSEventRunModal + 192
    17  GraphicsServices                    0x0480c42b GSEventRun + 104
    18  UIKit                               0x02b73f9b UIApplicationMain + 1225
    19  Translator                          0x000423ed main + 141
    20  libdyld.dylib                       0x053de701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [favouriteArray count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 110;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *simpleTableIdentifier = @"SimpleTableCell";

    simpleTableCell *cell = (simpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil)

    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"simpleTableCell" owner:self options:nil];

        cell = [nib objectAtIndex:0];

    }


    FavouriteDC *application = [favouriteArray objectAtIndex:[indexPath row]];

    cell.lblWord.text =  application.from_Lan;

    [cell setBackgroundColor:[UIColor clearColor]];

    cell.lblMeaning.text=application.to_Lang;

    return cell;




}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

}


- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{


    FavouriteDC * application = [favouriteArray objectAtIndex:[indexPath row]];

    // If row is deleted, remove it from the list.

    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        GET_DBHANDLER

        [dbHandler deleteFromFavorites:application.favo_id];

        [favouriteArray removeObjectAtIndex:indexPath.row];

        // delete your data item here

        // Animate the deletion from the table.

        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
withRowAnimation:UITableViewRowAnimationFade];

    }

}

1 个答案:

答案 0 :(得分:0)

您是否已使用情节提要或以编程方式将 Tableview委托设置为 UITableViewDelegate

通过编程将Tableview委托设置为UITableViewDelegate。

yourtableview.dataSource=self

使用情节提要将Tableview委托设置为UITableViewDelegate Tableview delegate to UITableViewDelegate