【发布时间】:2013-02-04 00:45:21
【问题描述】:
我正在尝试添加观察者 (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 代表collectionView。我不太确定该怎么做,因为我没有 customCell 作为属性,否则它无法编译。 有什么想法吗?
【问题讨论】:
标签: ios objective-c key-value-observing custom-cell kvc