我得到的UITableViewCell一个UIButton属于这样的:获取的UITableViewCell与上海华在iOS的7
-(void)buttonHandler:(UIButton *)button {
OrderCell *cell = [[button superview] superview];
NSLog(@"cell.item = %@", cell.item.text);
而且它在任何iOS的7前工作正常,但给我:
[UITableViewCellScrollView项目]:如果我在的iOS 7上运行应用程序,但如果我这样做发送到实例0x17ae2cf0
无法识别的选择:
-(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);
但跆拳道是怎么回事!? 有谁知道为什么会发生这种情况?
谢谢!
你的代码是根据的UITableViewCell的'私有子视图结构'。很明显,iOS 7中的结构已经发生了变化。有很多更安全的方法来执行您想要的操作。并且你的新代码将在iOS 7.1和iOS 8下破解。 – rmaddy
@rmaddy什么是更安全的方式? – Mundi
你可以遍历superviews,检查它们是否是类类型的UITableViewCell,然后返回该视图?看到回答: – CW0007007