我已經包含在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