Note that there are some explanatory texts on larger screens.

plurals
  1. PODCRoundSwitch as Accessory
    primarykey
    data
    text
    <p>I'm creating an ios app where I want to use a switch as the accessory for a tableview. I've found the following sample of how to use a UISwitch as the accessory: <a href="http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/ManageSelections/ManageSelections.html" rel="nofollow">http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/ManageSelections/ManageSelections.html</a> (see "Responding to Selections" section).</p> <p>What I'd like to do is to use a DCRoundSwitch (<a href="https://github.com/domesticcatsoftware/DCRoundSwitch" rel="nofollow">https://github.com/domesticcatsoftware/DCRoundSwitch</a>) instead of a UISwitch so I can customize the text. But when I create the accessory in the way that is suggested by the sample code, I just get the round knob, I don't get the whole switch. The code I'm using to add the accessory is:</p> <pre> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"PersonCell"; MyPerson *person = [self.dataController objectInListAtIndex:indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; DCRoundSwitch *switchObj = [[DCRoundSwitch alloc] initWithFrame:CGRectMake(1.0, 1.0, 20.0, 20.0)]; switchObj.onText = @"in"; switchObj.offText = @"out"; [switchObj addTarget:self action:@selector(personIn:) forControlEvents:(UIControlEventValueChanged | UIControlEventTouchDragInside)]; cell.accessoryView = switchObj; [[cell textLabel] setText:person.name]; [[cell detailTextLabel] setText:person.label]; return cell; } </pre> <p>What can I do to make the DCRoundSwitch work as a TableView accessory?</p> <p>Thanks!</p>
    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.
    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