UISwitch in a UITableView cell

前端 未结 6 1575
生来不讨喜
生来不讨喜 2020-11-30 21:57

How can I embed a UISwitch on a UITableView cell? Examples can be seen in the settings menu.

My current solution:

6条回答
  •  借酒劲吻你
    2020-11-30 22:47

    if (indexPath.row == 0) {//If you want UISwitch on particular row
        UISwitch *theSwitch = [[UISwitch alloc] initWithFrame:CGRectZero];
        [cell addSubview:theSwitch];
        cell.accessoryView = theSwitch;
    }
    

提交回复
热议问题