TableView实现Switch的方法

直接修改accessoryView即可。
CellForRow方法里写:

cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
UISwitch *switch=[[UISwitch alloc]init]; 
[switch addTarget:self action:@selector(switchValueChange:) forControlEvents:UIControlEventValueChanged]; 
cell.accessoryView=switch;

评论

此博客中的热门博文

使__attribute__((annotate("xxx")))能作用于OC函数

viewWillAppear不执行的解决办法

iOS中使用xpc/xpc.h