views:

219

answers:

2

I have a mainView. To this view, I am adding a view of the same size. When the mainView(the background) rotates, its being detected but the subview doesnt have any idea about being rotated. And its functions are not even being called. Even when the program launches too, if I am in landscape mode, its the same way.

How can I make the subView know that the device is being rotated?

A: 

Perhaps you can shoot an event from the mainView to the subView, like so (in mainView):

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
    [subView didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
cDima
I thought of that, but didnt try thinking that a better solution maybe available.
wolverine
A: 

You could fire an NSNotification when the main view is rotated, which the subview is registered to listen for. There's a quick overview of NSNotification over here.

One advantage of this approach is that objects other than subclasses of UIView can listen for this notification.

Alex Reynolds