Frage

Als ich die erste Zelle in meinem Tableview didSelectRowAtIndexPath tippen nicht ausgelöst wird ... Hat jemand scheint diese und / oder haben keine Ahnung, warum dies geschieht? Alle anderen Zellen in meinem Tisch gut funktionieren und ich habe einen Haltepunkt in meinem Code in didSelectRowAtIndexPath der App nicht in diesem Code nicht gehen, wenn die erste Zelle abgegriffen wird aber den Code gehen in, wenn die andere Zelle abgegriffen wird. Hier ist ein Code:

    - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = 0;
    return row;
}

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    if (row == 0)
        return nil;

    return indexPath;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //NSUInteger row = [indexPath row];
    //NSString *rowValue = [poolListData objectAtIndex:row];

    int newRow = [indexPath row];
    int oldRow = [lastIndexPathForPoolList row];

    if (newRow != oldRow)
    {
        UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
        newCell.accessoryType = UITableViewCellAccessoryCheckmark;

        UITableViewCell *oldCell = [tableView cellForRowAtIndexPath: lastIndexPathForPoolList]; 
        oldCell.accessoryType = UITableViewCellAccessoryNone;

        lastIndexPathForPoolList = indexPath;   
    }

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

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

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

    static NSString *DeleteMeCellIdentifier = @"DeleteMeCellIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DeleteMeCellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:DeleteMeCellIdentifier] autorelease];
    }

    NSInteger row = [indexPath row];
    cell.text = [self.poolListData objectAtIndex:row];
    return cell;
}

#pragma mark -
#pragma mark Table View Delegate Methods

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

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{   
    NSUInteger row = [indexPath row];
    [self.poolListData removeObjectAtIndex:row];
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

Vielen Dank für Ihre Zeit und jede Hilfe können Sie mir geben!

War es hilfreich?

Lösung

Ich denke, dass Ihre Rückkehr null in willSelectRowForIndexPath für die erste Reihe. Dadurch wird die Zeile verhindern, ausgewählt zu werden.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top