본문 바로가기

프로그래밍/iOS

[ios]화면 고정하기

가로 고정 시


-(BOOL)shouldAutorotate

{

    return YES;

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations

{

    return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

    return UIInterfaceOrientationLandscape;

}

// Deprecated in iOS 6.0

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    if (interfaceOrientation == UIInterfaceOrientationLandscape) {

        return YES;

    }

    return NO;

}

 

 

세로 고정 시


-(BOOL)shouldAutorotate

{

    return YES;

}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations

{

    return UIInterfaceOrientationMaskPortrait;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{

    return UIInterfaceOrientationPortrait;

}

// Deprecated in iOS 6.0

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    if (interfaceOrientation == UIInterfaceOrientationPortrait) {

        return YES;

    }

    return NO;

}