views:

181

answers:

1

Hi,

The challenge: i'd like to do some action if the user touches a TableItem.

The problem: The didSelectRowAtIndexPath method is never called? Did i miss sth?


PortfolioViewController.h

@interface PortfolioViewController : TTTableViewController <TTTableViewDelegate> 
{

}

@end

PortfolioViewController.m

@implementation PortfolioViewController

- (id)init {
 if (self = [super init]) {
  self.title = @"Portfolio";
  self.tableViewStyle = UITableViewStylePlain;
  self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth| UIViewAutoresizingFlexibleHeight;
  self.variableHeightRows = YES;  

  PortfolioDataSource *ds = [[[PortfolioDataSource alloc] init] autorelease];
  CasesModel *cm = [[[ CasesModel alloc] init] autorelease];
  ds.model = cm; 

  self.dataSource = ds;

 }
 return self;
}

#pragma mark -
#pragma mark Table Delegate Methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
 NSLog(@"touched");
}


@end
+1  A: 

You don't need to change the delegate for simple operations. Just implement this method in your controller:

- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath;

Source: I do it... and the three20 source file

coneybeare
Yeah, thanks!!!
fabian