1

iOSで、デバイスが縦向きモードから横向きモードに回転したときにUI要素(ボタンとラベル)を移動するにはどうすればよいですか?

4

1 に答える 1

0

たくさんの方法があります。

私の場合、通知を使用しています

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rotated:) name:UIDeviceOrientationDidChangeNotification object:nil];

回転方式の場合

-(void) rotated: (NSNotification*) notification
{
    orientation = [[UIDevice currentDevice] orientation];
        if(UIDeviceOrientationPortraitUpsideDown==orientation) 
// UI relocation
else if(UIDeviceOrientationPortrait==orientation)
// UI relocation
else if(UIDeviceOrientationLandscapeRight==orientation)
// UI relocation
else if(UIDeviceOrientationLandscapeLeft==orientation)
// UI relocation
}
于 2013-02-24T22:52:17.360 に答える