3

I often use IBOutletCollection to be able to reference UIView objects sequentially.

For example, I can enumerate ordered list of UIButtons, get numerical indice of them, without making same number of IBOutlet for each of them. It's very useful, especially if your view contains somethings like numeric key buttons.

However, for this method to work properly, the IBOutletCollection MUST be ordered, and must return same index number for the object. When I have been using .xib, the order of objects in IBOutletCollection array is same as the order of connecting the objects to this IBOutletCollection in Interface Builder.

The problem occurs when I try to do same thing within a Scene of the Storyboard. I am not sure if it has to do with UIViewController or Storyboard, but same solution which have been working for me when I use separate .xib doesn't work properly.

The index number is not ordered and changed when the object is instantiated again.

Does anyone experience the same problem? Or is there anything I overlooked?

petershine
  • 3,190
  • 1
  • 25
  • 49
  • I get the same problem. I've been using it fine in xibs then I used it in storyboard and the ordering changes everytime the storyboard loads. I gotta sort it now :( – yuf Nov 14 '12 at 18:46
  • I have 10 UIButtons within a collection that work just fine. I've 30 UILabels within a collection that have been completely randomised. Did you find a way to do this? – Declan McKenna Feb 27 '13 at 21:46
  • @Deco So far I've been able to structure my development to limit the usage of IBOutletCollection within a separate .xib file. It looks like a flaw in just Storyboard, which is yet to be corrected. Still waiting for the fix – petershine Mar 06 '13 at 13:44
  • @PeterSHINe신동혁 Ye definitly a storyboard issue. It weren't an elegant fix but I got round this by assigning tags to all the elements within my IBOutletCollection and then sorted them when launching. – Declan McKenna Mar 07 '13 at 03:27

0 Answers0