Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Z-hui opened this issue Sep 17, 2019 · 1 comment
Open

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

Z-hui opened this issue Sep 17, 2019 · 1 comment

Comments

@Z-hui
Copy link

Z-hui commented Sep 17, 2019

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的第五个在一个层级吗

@AirChen
Copy link

AirChen commented May 16, 2020

@Z-hui 感觉可以用集合求交集运算

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants