for (int i = 1; i < [[[UILocalizedIndexedCollation currentCollation] sectionTitles] count]+1; i++) {
HeaderButton *headerLabel = (HeaderButton *)[tileView viewWithTag:i];
}
Hi all, I’m using a For Loop to loop through a grid of Buttons I have in my XIB file. For the English Localization, it works 100% and finds all 26 buttons in the grid.
If you’ll notice, I’m using LocalizedIndex which will return the appropriate “less than NUMBER_HERE” statement for me. For Japanese, it returns < 38, which should find all 37 buttons.
Now the weird issue. The SAME for loop for Japanese, Spanish or even Chinese localizations WILL NOT WORK PROPERLY.
I’m losing my mind. I’ve inserted NSLog statements, and it’s telling me that, it finds buttons with Tags up to 27, (out of a possible 37 for Japanese, 30 for Spanish etc etc) then it crashes on 28 telling me that:
-[UIView setTitle:forState:]: unrecognized selector sent to instance 0x1dd6b640
I know that UIView doesn’t have a setTitle:forState: method. I’m using the cast statement above to point to my Button Subclass buttons that are in a specific view. Like I said, for English this works 100%, but for anything else it doesn’t.
There is no reason why this should be happening. My code is 100% correct. It’s Xcode that seems to have an issue with viewWithTag of 28.
Any ideas?
Regards,
cocotutch
Here’s some code you can use to debug, as well as keep later once you get this sorted out. Not knowing much about the project, it sure looks like viewWithTag is finding a type that you don’t expect. Let’s replace the blind cast with an introspective test…