user930195
user930195

Reputation: 432

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 my DeatilViewController.xib and they belongs to which class.

How can i do this?

Upvotes: 1

Views: 347

Answers (2)

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73588

Try NSArray *subViews = [DeatilViewController.view subviews]; or for their count

NSInteger count = [[DeatilViewController.view subviews] count];

Upvotes: 1

Krumelur
Krumelur

Reputation: 33048

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

Upvotes: 0

Related Questions