I added a UILabel subview using code. When the user rotates the iPad, I want to be able to tell that UILabel to shift its position to accomodate the new screen orientation.
I think I need to put my code in the willAnimateRotationToInterfaceOrientation function.
I want to be able to get at my UILabel and I see sample code that looks like the following to retrieve a reference to a subview:
UILabel *myLabel = (UILabel *) [self.subviews objectAtIndex:0];
How do I know what index my UILabel is at? The sample code seems to know that their subview is the first one (index 0).
Is there a way for me to find out what my UILabel’s index is?
Is there another way to keep a reference to this UILabel that I create in code? If I made myLabel a variable of the class, will I be able to reference
Generally, in your UIViewController, you’d have an instance variable that was a pointer to your UILabel. Then you can access it anywhere in your controller’s code.