相关疑难解决方法(0)

在iOS 7中使用superview获取UITableViewCell

我得到的UITutView属于UIButton属于这样:

-(void)buttonHandler:(UIButton *)button {

    OrderCell *cell = [[button superview] superview];
    NSLog(@"cell.item = %@", cell.item.text);
Run Code Online (Sandbox Code Playgroud)

在iOS 7之前它可以正常工作.但是给了我:

[UITableViewCellScrollView item]:无法识别的选择器发送到实例0x17ae2cf0

如果我在iOS 7中运行该应用程序.但如果我这样做:

-(void)buttonHandler:(UIButton *)button {

    OrderCell *cell = [[[button superview] superview] superview];
    NSLog(@"cell.item = %@", cell.item.text);
Run Code Online (Sandbox Code Playgroud)

然后它可以在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);
Run Code Online (Sandbox Code Playgroud)

但是WTF还在继续!?有谁知道为什么会这样?

谢谢!

objective-c superview ios

9
推荐指数
2
解决办法
7332
查看次数

标签 统计

ios ×1

objective-c ×1

superview ×1