我已经包含在NSMutableDictionnary产品的列表,我diplsay它是这样的:检测点击的UITableView
现在,我想补充一个观点每一个产品。如果我点击“紫苏”对于为例我要切换视图,并有一个新的观点,产品细节或别的东西..
我添加以下代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath];
// Configure the cell...
NSString *sectionTitle = [aromaSectionTitles objectAtIndex:indexPath.section];
NSArray *sectionAroma = [tableData objectForKey:sectionTitle];
NSString *aromaLabel = [sectionAroma objectAtIndex:indexPath.row];
cell.textLabel.text = aromaLabel;
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.userInteractionEnabled = YES;
cell.textLabel.tag = indexPath.row;
UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(buttonPressed:)];
tapped.numberOfTapsRequired = 1;
[cell.textLabel addGestureRecognizer:tapped];
return cell;
}
-(void)buttonPressed :(id) sender {
UITapGestureRecognizer *gesture = (UITapGestureRecognizer *) sender;
NSLog(@"Tag = %ld", (long)gesture.view.tag);
}
在我的日志ID,但它不是唯一的,id是产品的行号,这里Armoise将是0,ArbreThé1,但是Basilic将是0并且Baie将会是1等等。 我该如何创建根据用户的选择查看?
非常感谢您的帮助!
你只是想要一个细胞是可点击?有一个委托方法。 tableView:didSelectRow:atIndexPath: – CW0007007 2014-09-01 12:46:05
我想在描述产品的视图上重定向用户 – 2014-09-01 12:50:20