0
在我UITableView
的第二部分的UITableViewCell
,我已經定義了一個UISegmentedControl
的兩個按鈕組成:在操控性上UISegmentedControl點擊
if (indexPath.section == 1 && indexPath.row == 0)
{
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryNone;
allerRetour = [[UISegmentedControl alloc] initWithItems: [NSArray arrayWithObjects:NSLocalizedString(@"Y aller", nil), NSLocalizedString(@"En partir", nil), nil]];
[allerRetour setFrame:CGRectMake(9.0f, 0.0f, 302.0f, 45.0f)];
allerRetour.selectedSegmentIndex = 0;
[cell addSubview:allerRetour];
}
return cell;
現在,當我點擊兩個按鈕中的一個按鈕分段控制,我想跟蹤,所以我嘗試這在didSelectRowAtIndexPath
,但它不工作(該的NSLog不會顯示,因此不拋出的事件):
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section==1 && indexPath.row==0)
{
if (allerRetour.selectedSegmentIndex == 0)
{
[email protected]"Départ";
NSLog(@"Départ");
}
else
{
[email protected]"Arrivée";
NSLog(@"Arrivée");
}
}
}
我已經這樣做了,我看了一下UISegmentedControl的文檔,但是,沒有什麼改變,但是你的方法適用於很多其他情況,可能不是我的:) – Malloc 2012-01-10 15:26:16
你是什麼意思,它不適合?你是否試圖讓這個工作在多行上?我可以幫助(如果需要,請用法語:)) – 2012-01-10 15:28:16