我正在获取 UIButton 所属的 UITableViewCell,如下所示:
-(void)buttonHandler:(UIButton *)button {
OrderCell *cell = [[button superview] superview];
NSLog(@"cell.item = %@", cell.item.text);
它在 iOS 7 之前的任何东西上都可以正常工作。但是给了我:
[UITableViewCellScrollView item]:无法识别的选择器发送到实例 0x17ae2cf0
如果我在 iOS 7 中运行该应用程序。但如果我这样做:
-(void)buttonHandler:(UIButton *)button {
OrderCell *cell = [[[button superview] superview] superview];
NSLog(@"cell.item = %@", cell.item.text);
然后它可以在 iOS 7 中运行,但不是更早的版本?!?!?!
我通过这样做来规避这个问题:
OrderCell *cell;
if([[[UIDevice currentDevice] systemVersion] isEqualToString:@"7.0"])
cell = [[[button superview] superview] superview];
else
cell = [[button superview] superview];
NSLog(@"cell.item = %@", cell.item.text);
但是WTF正在进行中!?有谁知道为什么会这样?
谢谢!