방향에 따라 UILable의 위치를 프로그래밍 방식으로 설정하려고합니다. 하지만 Portrait로 돌아 가면 작동하지 않습니다. 사전에iPhone 오리엔테이션 변경 프레임
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown)
{
lblUserName.frame = CGRectMake(20, 200, 280, 44);
lblPassword.frame = CGRectMake(20, 246, 280, 44);
}
else
{
lblUserName.frame = CGRectMake(20, 220, 280, 44);
lblPassword.frame = CGRectMake(20, 266, 280, 44);
}
}
감사 :
여기 내 코드입니다.
현재 방향 확인을 위해 toOrienation을 사용했습니다. – NSPratik
statusBarOrientation 메서드를 너무 일찍 호출하면 장치가 아직 회전하지 않으므로 statusBarOrientation이 회전중인 회전을 반환합니다. – Otium