UItableviewcell中的复选框

时间:2010-09-07 10:26:40

标签: iphone

我从网址引用 link text

我可以在tableview上显示复选框。 现在点击按钮我想检查选中了哪个复选框。我可以这样做吗?

在建议使用NSnotification的网址“Amagrammer”中,任何人都可以为我提供一个教程。

    - (void) toggleImage
{
   selected = !selected;
   imageView.image = (selected ? selectedImage : normalImage); 

   // Use NSNotification or other method to notify data model about state change.
   // Notification example:
   NSDictionary *dict = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt: self.tag forKey: @"CellCheckToggled"];
   [[NSNotificationCenter defaultCenter] postNotificationName: @"CellCheckToggled" object: self userInfo: dict];

}

1 个答案:

答案 0 :(得分:0)

In your view controller or somewhere you handle the data You add a observer

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(YOUR__FUNCTION) name:@"CellCheckToggled" object:nil];

Then you can do sth in YOUR__FUNCTION with your userInfo

-(void)YOUR__FUNCTION: (NSNotification*) aNotification
{
dict = [aNotification userInfo];

}