0

挑战: 如果用户触摸 TableItem,我想做一些动作。

问题:从不调用 didSelectRowAtIndexPath 方法?我错过了什么?


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
4

1 回答 1

2

您无需更改委托即可进行简单操作。只需在您的控制器中实现此方法:

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

来源:我做...和three20源文件

于 2010-02-15T18:10:11.523 回答