0

我正在尝试添加观察者(KVO)来观察我的自定义单元格。选择单元格后,我应该会收到事件通知。我的代码:

[colMain addObserver:self forKeyPath:@"colMain" options:0 context:NULL];

}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{

    if (keyPath == @"colMain") {
        NSLog(@"cell Selected");
        [self performSelector:@selector(deleteCell) withObject:nil];

    }
}

colMain 代表集合视图。我不太确定该怎么做,因为我没有 customCell 作为属性,否则它无法编译。有任何想法吗?

4

1 回答 1

3

为什么不在你的集合视图上设置一个委托,然后实现这两种方法之一呢?

[– collectionView:shouldSelectItemAtIndexPath:]

[– collectionView:didSelectItemAtIndexPath:]

于 2013-02-04T00:55:53.700 回答