views:

39

answers:

1

I have a tableview that uses a custom UITableViewCell. In the cell, I have a button that shows a custom menu controller with three menu items. I would like to push a new view controller when you click the 'See Detail' button.

I have this run when the 'See Detail' button is clicked in the custom cell

- (void)seeDetail:(UIMenuController *)controller
{
 NSLog(@"See detail clicked");
 parentMovers = [[ParentViewController alloc] init];
 [parentMovers showStockDetail];
}

And showStockDetail is in the view controller that fills in the rows.

-(void)showStockDetail {
 NSLog(@"show stock detail");

 ChildViewController *childViewController = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil];
 childViewController.tickerId = tickerId;
 [self.navigationController pushViewController:childViewController animated:YES];
 [stockDetailViewController release];
}

This doesn't show the detail view controller. I also tried to add the code in showStockDetail to -(void)seeDetail:(UIMenuController *)controller

Any ideas on how I can get this to work?

A: 

Off the top, you're leaking memory in both methods -- parentMovers in seeDetail:, and childViewController in showStockDetail (which is also doing a release on a magic variable named stockDetailViewController).

I'm a little confused by the design you're using, so maybe telling you how I'd do it will help.

If I had a table view, with custom cells, that had buttons in them, I would hook those buttons up to my view controller subclass (touchUpInside), so when they are tapped my view controller then shows the appropriate "child" view controller (filling it with the appropriate detail based on which button was tapped).

I would not put this logic in the custom cell class. It makes sense to delegate/defer the action to the view controller.

Shaggy Frog