nib 파일 someNib.xib에 있다고 가정 해 보겠습니다.beginGeneratingDeviceOrientationNotifications에 의해 생성 된 메소드 호출 중지
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationChanged)
name:UIDeviceOrientationDidChangeNotification object:nil];
무엇을이 라인이하는 것은이 장치가 회전하는 deviceOrientationChanged 방법의 초과 근무를 호출하는 것입니다 : 장치 방향이 후 변경 한 경우 나에게 말할 수 있기 위해서는 내가보기 안쪽이 부하 방법을했다 놓습니다. 내 deviceOrientationChanged 메소드는 다음과 같습니다.
-(void) deviceOrientationChanged{
if(self.view.frame.size.width<800)
{
//means device is on portrait mode
} else {
//means device is on landscape mode
}
}
이렇게 모든 것이이 nib 파일과 잘 맞습니다. 문제는 다음과 같이 다른 nib 파일을로드 할 때 발생합니다.
// release allocated variables
// VCHome is the name of the nib file
VCHome *control = [VCHome alloc];
[control initWithNibName:@"VCHome" bundle:nil];
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:control];
[self presentModalViewController:navControl animated:YES];
[navControl setNavigationBarHidden:YES];
[control release];
[navControl release];
이 시점까지 모든 것이 잘 작동합니다. 나는 이제 새로운 펜촉 파일에 있으며 VCHome과 상호 작용할 수 있습니다.
VCHome nib 파일을 사용할 때 장치를 회전시킬 때 deviceOrientationChanged 메서드가 호출되는 이유는 무엇입니까? VCHome nib 파일을로드했을 때 someNib (마지막 펜촉)을 릴리스해야이 메서드가 호출되지 않습니다. someNib을 더 이상 사용할 계획이 없으며 someNib을로드 한 적이없는 것처럼 VCHome 펜촉을 사용하고 싶습니다.