PDA

View Full Version : question about willAnimationRotate and didRotateFrom, iphone




tranvutuan
Feb 11, 2012, 11:10 AM
What I am having so far is
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{

NSLog(@"willAnimateRotationToInterfaceOrientation");
if(toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"PortraitUpsideDown");
// Do method A
}
else {
[[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
// Do method B

}
}
and
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
NSLog(@"didRotateFromInterfaceOrientation");
if( fromInterfaceOrientation == UIInterfaceOrientationPortrait || fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
NSLog(@"OrientationPortrait or PortraitUpsideDown");
[[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
// Do method B
}
else {
NSLog(@"From else");
[[self.view subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
// Do method A

}
}

My logic is after hitting the RUN from xcode, willAnimateRotationToInterfaceOrientation is going to be called because I set Supported Device Orientation to be UpsideDown from Summary of MyApp.xcodeproj.Moreover, I also think that didRotateFromInterfaceOrientation should not be called because we have just started the app yet. It means there is no previous state at all.
Unfortunately, this is what I got after doing the debugger
2012-02-11 12:04:08.776 MyApp[7505:10703] willAnimateRotationToInterfaceOrientation :
2012-02-11 12:04:08.776 MyApp[7505:10703] PortraitUpsideDown
2012-02-11 12:04:08.778 MyApp[7505:10703] didRotateFromInterfaceOrientation :
2012-02-11 12:04:08.779 MyApp[7505:10703] OrientationPortrait or PortraitUpsideDown
I am getting lost now. Does anyone have any ideas about the issue, please help. Thanks.



lefooey
Feb 11, 2012, 02:47 PM
Apps always start in the same interface orientation as the springboard. On an iPhone or iPod touch, this is always UIInterfaceOrientationPortrait. Thus, if you have the device positioned upside down, the app starts in portrait and your root view controller receives the orientation change as soon as the window becomes visible.

tranvutuan
Feb 11, 2012, 08:09 PM
Apps always start in the same interface orientation as the springboard. On an iPhone or iPod touch, this is always UIInterfaceOrientationPortrait. Thus, if you have the device positioned upside down, the app starts in portrait and your root view controller receives the orientation change as soon as the window becomes visible.
Thanks for your answer, it helps me to understand the reason now.