Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法找出视图堆栈中当前有多少视图?只是好奇地想知道当代码将一个视图推到另一个视图时它在任何时候有多大......
您应该能够使用 UIView 上的类别添加自己的对递归计数子视图的支持:
@implementation UIView (SubviewCount) - (NSUInteger)subviewCount { NSUInteger count = [[self subviews] count]; for (UIView *view in [self subviews]) count += [view subviewCount]; return count; } @end