在iphone的另一个类中传递toggle button值以切换按钮状态

在iphone的另一个类中传递toggle button值以切换按钮状态,iphone,objective-c,ios,Iphone,Objective C,Ios,我有一个应用程序,其中有2个tableview控制器。在第一个tableview中,我在我的cellforRowAtIndexPath中创建了一个按钮,该按钮位于我的第一个tableview中。最初,我已将按钮图像设置为“打开”图像,这意味着我的警报已打开。然后,当我单击“编辑”按钮时,我的tableview将更改为“编辑模式”,我可以将按钮图像更改为“关闭”。我希望在tableview进入编辑模式时调用我的按钮操作。这是我编写的代码 - (UITableViewCell *)tableView

我有一个应用程序,其中有2个tableview控制器。在第一个tableview中,我在我的cellforRowAtIndexPath中创建了一个按钮,该按钮位于我的第一个tableview中。最初,我已将按钮图像设置为“打开”图像,这意味着我的警报已打开。然后,当我单击“编辑”按钮时,我的tableview将更改为“编辑模式”,我可以将按钮图像更改为“关闭”。我希望在tableview进入编辑模式时调用我的按钮操作。这是我编写的代码

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
       NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d", indexPath.section, indexPath.row];
    appDelegate = (StopSnoozeAppDelegate*)[[UIApplication sharedApplication]delegate];
    TAlarmCell *cell =(TAlarmCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[TAlarmCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        mimageButton = [UIButton buttonWithType:UIButtonTypeCustom];
        mimageButton.frame=CGRectMake(10, 20, 20, 20);   
        mimageButton.tag = 1;     
        [mimageButton setImage:[UIImage imageNamed:@"alarm_ON.png"] forState:UIControlStateNormal]; 
        [mimageButton setImage:[UIImage imageNamed:@"alarm_OF.png"] forState:UIControlStateSelected]; 
        [cell.contentView addSubview:mimageButton];   
    }
    cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;

 return cell;
}
//这是我的编辑代码

-(void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing:editing animated:animated];
    [mTableView setEditing:editing animated:YES];
    if (editing)
    {
        [mimageButton addTarget:self action:@selector(changeMapType:) forControlEvents: UIControlEventTouchUpInside]; 
        self.navigationItem.rightBarButtonItem = nil;

    }
    else {
        self.navigationItem.rightBarButtonItem = addButton;
        [self.mTableView reloadData];
    }

}
//这是我的按钮动作

-(void)changeMapType:(UIButton *)sender
{
    NSIndexPath *indexPath =[self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]]; 

    NSUInteger row = indexPath.row; 
    NSLog(@"row...%d",row);
    appDelegate.changeimagetype = !appDelegate.changeimagetype;
    sender.selected = appDelegate.changeimagetype;
    [self.tableView reloadData];
}

但是这里的问题是当我点击编辑按钮,tableview进入编辑模式时,changeMapType:action没有被调用,我的图像也没有改变。

你能给我一些关于

在哪里设置此标志

if (editing)
对于用户的哪个操作,您希望调用此方法

-(void)changeMapType:(UIButton *)sender
如果你想在进入编辑模式后立即被调用,你可以使用下面的方法

[self performSelector:@selector(changeMapType:)];

我的tableview中有一个按钮,上面有一个on。当我单击该按钮时,该按钮的图像应仅针对该特定单元格更改。我的问题是,当我单击该按钮时,所有indexpath的图像都会更改,然后我想将按钮状态传递给其他类中的switchbutton。