views:

175

answers:

1

Hi! I have a BlahAppDelegate, BlahViewController and no nibs in my iPhone app project. Only some subclasses of UIView in addition. All this is situated in main.m. My app has 6 subclassed UIViews. Each of it contains 18 UIImageViews.

I need to get autorotating work. Or custom rotating. Or something. For example it would be nice to fade the screen out when device is rotated, then move/resize views and then fade screen out. But I don't know how to automate it, without writing a resizing code for each of objects.

Please help me if you can.

+1  A: 

The simplest approach would be to use the autoresizingMask property of your image views. These act just like the springs-and-struts in IB. If you position your views relative to their parents, and set these appropriately, you should have no problems. However, your options are somewhat limited; basically fixed distance from the edge, or proportionally spaced. No child-relative alignment is possible using just the flags.

Ben Gottlieb
I don't use IB in my project, or I just misunderstood your comment. Can you give some code on how to implement that please?
Denis
the autoresizingMask (thanks Noah!) is a complex beast. You're definitely going to want to read the doc on it. It might also help to play with IB's springs-and-struts (that's the resizing section) to get a feel for how they affect your view bounds. Basically, using an OR'd combination of the auto-resizing flags, you can make your width and height shrink or grow with the parent.
Ben Gottlieb
For example, to make your child view stay centered horizontally in its parent, and maintain its width, even as you change the parent's bounds, set its autoresizingMask to UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin.
Ben Gottlieb