Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tranvutuan

macrumors member
Original poster
Dec 19, 2011
74
0
What I am having so far is
Code:
-(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
Code:
- (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
Code:
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.
 
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.
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.