static NSString *strone=@"111111111111111";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:strone];
if (cell==nil) {
cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strone]autorelease];
UISwitch* mySwitch = [[ UISwitch alloc]initWithFrame:CGRectMake(230, 10, 20, 30)];
// [mySwitch setBackgroundImage:[UIImage imageNamed:@"bgBlueButton.png"] forState:UIControlStateNormal];
[ mySwitch setOn:NO animated:YES];
[mySwitch setTag:indexPath.row];
[mySwitch addTarget:self action:@selector(del:) forControlEvents:UIControlEventValueChanged];
[cell addSubview:mySwitch];
}
cell.textLabel.text=[clocknum objectAtIndex:indexPath.row];
// [cell.lable setText:[arr objectAtIndex:indexPath.section]];
// [cell imagepeople].image=[UIImage imageNamed:[NSString stringWithFormat:@"%@%d",PEOPLETRING,indexPath.section]];
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [数组 count];
}
//添加
//初始时,数组为空,在数组有变化时
[tableclock reloadData];
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//点击后反显颜色即刻消失
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[tableView setEditing:YES];
}
//编辑状态
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSUInteger row = [indexPath row];
//从数据源中移除数据
[clocknum removeObjectAtIndex:row];
NSLog(@"===%d",[clocknum count]);
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
[tableclock reloadData];
[tableView setEditing:NO];
}
}