Skip to content

Commit

Permalink
add method that search for a superview of a particular class
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Morris committed Jan 19, 2014
1 parent 64efb6e commit ad0fcef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Utils/UtilitiesUI.h
Expand Up @@ -137,6 +137,11 @@ void setNavController(UINavigationController* newNavController);
//-----------------------------------------------------------------------------
void tellParentToDismissModalVC(UIViewController* viewController);

//-----------------------------------------------------------------------------
// findSuperviewOfClass
//-----------------------------------------------------------------------------
UIView* superviewOfClass(Class target, UIView* fromView);

#ifdef DEBUG
//-----------------------------------------------------------------------------
// dumpWindows - prints the windows and their subview hierarchy in console log
Expand Down
15 changes: 14 additions & 1 deletion Utils/UtilitiesUI.m
Expand Up @@ -440,7 +440,20 @@ void tellParentToDismissModalVC(UIViewController* viewController)
}
}


//-----------------------------------------------------------------------------
// findSuperviewOfClass
//-----------------------------------------------------------------------------
UIView* superviewOfClass(Class target, UIView* fromView)
{
UIView* curView = fromView.superview;
while (curView != nil && curView != fromView.window) {
if ([curView isKindOfClass:target]) {
return curView;
}
curView = curView.superview;
}
return nil;
}



Expand Down

0 comments on commit ad0fcef

Please sign in to comment.