Currently i am generating "n" number of custom views in my DeatilViewController screen.So i want to calculate the number of views present in 开发者_JAVA百科my DeatilViewController.xib
and they belongs to which class.
How can i do this?
Try NSArray *subViews = [DeatilViewController.view subviews];
or for their count
NSInteger count = [[DeatilViewController.view subviews] count];
UIViewController
has a property called view
that returns the controller's view. This UIView
in turns has a property subviews
that returns the subviews of the view.
Get the length of this array and you got your subviews.
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/c_ref/UIView
精彩评论