Note that there are some explanatory texts on larger screens.

plurals
  1. POretrieve the row table id when I click the switch?
    primarykey
    data
    text
    <p>I have a table view with switch control. My problem is: how can I retrieve the row table id when I click the switch? I can retrieve the switch state but not the id</p> <p>This is my code to get the state of switch:</p> <pre><code>- (void)aggiungiTag:(id)sender { NSLog(@"the tag value is: %d", [sender isOn]); return; } </code></pre> <p>This is my code to make push switch control into cell:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } // Configure the cell... //inseriamo nelle celle la nostra lista cell.textLabel.text = [arrTagResidui objectAtIndex:indexPath.row]; /*** aggiungo lo switch per i tag ***/ //lo istanzio e setto la posizione UISwitch *switchObj = [[UISwitch alloc] initWithFrame:CGRectMake(1.0, 1.0, 20.0, 20.0)]; //setto il valore di default switchObj.on = NO; //setto l'action ed i controlli degli eventi [switchObj addTarget:self action:@selector(aggiungiTag:) forControlEvents:(UIControlEventValueChanged | UIControlEventTouchDragInside)]; //aggiungo lo switch alle celle cell.accessoryView = switchObj; NSInteger row = indexPath.row; [arrBoolSwitch insertObject:[NSNumber numberWithBool:NO] atIndex:row]; [switchObj release]; return cell; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload