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

Fix: Introspector in iOS 14 not working for ScrollView (#55) #56

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Introspect/Introspect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public enum Introspect {
return nil
}

/// Finds a previous sibling that contains a view of the specified type.
/// Finds a previous sibling that is or contains a view of the specified type.
/// This method inspects siblings recursively.
/// Returns nil if no sibling contains the specified type.
public static func previousSibling<AnyViewType: PlatformView>(
Expand All @@ -67,6 +67,10 @@ public enum Introspect {
}

for subview in superview.subviews[0..<entryIndex].reversed() {
if let typed = subview as? AnyViewType {
return typed
}

if let typed = findChild(ofType: type, in: subview) {
return typed
}
Expand Down Expand Up @@ -124,7 +128,7 @@ public enum Introspect {
return nil
}

/// Finds a next sibling that contains a view of the specified type.
/// Finds a next sibling that is or contains a view of the specified type.
/// This method inspects siblings recursively.
/// Returns nil if no sibling contains the specified type.
public static func nextSibling<AnyViewType: PlatformView>(
Expand All @@ -139,6 +143,10 @@ public enum Introspect {
}

for subview in superview.subviews[entryIndex..<superview.subviews.endIndex] {
if let typed = subview as? AnyViewType {
return typed
}

if let typed = findChild(ofType: type, in: subview) {
return typed
}
Expand Down