There is a problem when i am getting index of subview.
int index = [[YourUIView subviews] indexOfObject:YourUIButton];
Some UITextField are created with xib file. When i printed its value i get unreal index.
@property (nonatomic, retain) IBOutlet UITextField *distanceTextField; for example: index is equal to 2147483647
But when i add object programmatically i get real index. index is equal to 12. Why ?
Each time you perform a search for some index (or range) with framework methods check its result against
NSNotFoundconstant. On your platform NSNotFound is happened to be 2147483647. That solves the mystery of unreal index.As for question why your view is not found – check if every outlet actually points to some view at the moment you perform this search.
Update
You can check if outlet is set with debugger or by logging it