Skip to content

查找两个视图的公共父视图那个对吗 #5

@Z-hui

Description

@Z-hui
while (i < MIN((int)arrayOne.count, (int)arrayOther.count)) {
    // 倒序方式获取各个视图的父视图
    UIView *superOne = [arrayOne objectAtIndex:arrayOne.count - i - 1];
    UIView *superOther = [arrayOther objectAtIndex:arrayOther.count - i - 1];
    
    // 比较如果相等 则为共同父视图
    if (superOne == superOther) {
        [result addObject:superOne];
        i++;
    }
    // 如果不相等,则结束遍历
    else{
        break;
    }
}

查找两个视图的公共父视图那个对吗?两个view一定是都是第n个相同吗?不可以第一个view的第三个 和第二个view的第五个在一个层级吗

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions