I want to list out all the subviews in a UIViewController
. I tried self.view.subviews
, but not all of the subviews are listed out, for instance, the subviews in the UITableViewCell
are not found. Any idea?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
I have done it in a category of
UIView
just call the function passing the index to print them with a nice tree format. This is just another option of the answer posted by James Webster.I hope it helps :)
The reason the subviews in a UITableViewCell are not printed is because you must be outputting all the subviews in the top level. The subviews of the cell are not the direct subviews of your view.
In order to get the UITableViewCell's subviews, you need to determine the which subviews belong to a UITableViewCell (using
isKindOfClass:
) in your print loop and then loop through it's subviewsEdit: This blog post on Easy UIView Debugging may potentially help
Elegant recursive solution in Swift:
You can call subviewsRecursive() on any UIView:
I'm a bit late to the party, but a bit more general solution:
A C# Xamarin version:
Alternatively, if you want to find all the subviews of a specific type I use:
You need to print recursively, this method also tabs based on the depth of the view