开发者

How to calculate number of views in my viewcontroller

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜