views:

183

answers:

1

hey people ,

I have a question concerning a button I would like to create which selects my previous selected row. This is what I came up so far but since I'm new with the functionality and such I could definately use some pointers

I created a toolbar with a button and behind this button is the following action.

-(void)clickRow
{
selectedRow = [self.tableView indexPathForSelectedRow];
[self.tableView:[self tableView] didSelectRowAtIndexPath:selectedRow];
}

in my didSelectRowAtIndexPath

there is a rootViewController being pushed

rvController = [RootViewController alloc] ...etc

So what I would like is my function clickRow to select the row and push the new rootviewcontroller (which has the right info since I'm using a tree ).

I tried something like this as well

    -(void)clickRow
    {
    NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row];

    NSArray *Children = [dictionary objectForKey:@"Children"];

    rvController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]];

    rvController.CurrentLevel += 1;

    rvController.CurrentTitle = [dictionary objectForKey:@"Title"];

    [self.navigationController pushViewController:rvController animated:YES];
    rvController.tableDataSource = Children;
    [rvController release];
}

The last function works a little but a little is not enough;) For instance if I press the middle row or any other it constantly selects the toprow.

thnx all for those of you reading and trying to help

+1  A: 

Well the problem here i believe is [self.tableView indexPathForSelectedRow]; From what this is looking like, it seems that perhaps the cells are not "staying" selected when the user clicks on them therefore you are getting the top row index returned when you call indexPathForSelectedRow, look into the table cell docs and check out if there is anything in there http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableViewCell%5FClass/Reference/Reference.html, if not, what i would do is when the person clicks on the row capture the index path in a class variable and then use that..

Daniel