2013-01-29 7 views
0

현재 일부 그림이있는 scrollview 있습니다. 휴대 전화를 가로 방향으로 회전 시키면 전체 화면이 이미지로 덮 이도록 scrollview의 그림이 커지도록 (전체 화면) 원합니다. 다시 세로로 회전 시키면 전체 화면 이미지가 제거됩니다.회전 전체 화면에 UIImageView 표시

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

하고 처리하기 : I 회전 변화 감지 내 viewDidLoad에 지금까지 무슨 짓을

- (void)handleOrientationChange 
{ 
    if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) || 
    ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) { 
     UIImageView *fullScreenImage = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
     [fullScreenImage setImage:[UIImage imageNamed:[[PflanzenSingletonClass sharedManager] loadStringFromUserDefaultsForKey:CurrentScrollViewImage]]]; 
     [fullScreenImage setTag:999]; 
     [self.view addSubview:fullScreenImage]; 
    } else 
    { 
     [[[self.view subviews] objectAtIndex:([[self.view subviews] count] - 1)] removeFromSuperview]; 
    } 
} 

을하지만 (분명 내 잘못을) 예상대로 작동하지 않습니다.

  1. ImageView는 실제로 전체 화면이 아닙니다. 내비게이션 막대가 계속 표시됩니다.
  2. 이미지가 가로 방향으로 회전하지 않습니다. 방향 변경이 발생하기 직전에 제 방법이 호출됩니까?
  3. 2. 때문에 이미지가 늘어납니다.
  4. 애니메이션을 사용하여 훨씬 더 매끄럽게 만들고 싶습니다. 시작점은 scrollview의 rect입니다.

아이디어가 있으십니까? 고마워. 당신의 ViewController에서이 문제를 해결할 경우

답변

0

, 당신은 사용 통지 대신 다음 메소드를 오버라이드 (override) 할 수 있습니다

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation) 
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) 
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation) 

당신이 keyWindow에 추가 할 수 있습니다 이미지 뷰 전체 화면을 만들려면 (및 탐색 막대 위로를 표시) :

UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; 
[imageView setFrame:keyWindow.bounds]; 
[keyWindow addSubview:imageView]; 

업데이트.

UIImageView를 모달로 표시되는 별도의 UIViewController로 표시 할 수도 있습니다. 이의 ViewController에서 또한 당신의 응용 프로그램 지원 가로 및 세로 두 방향을 확인

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toOrientation { 
    if (UIInterfaceOrientationIsPortrait(toOrientation)) { 
     [self dismissModalViewControllerAnimated:]; 
    } 
} 

방법

를 구현합니다. 요약 탭이나 App-Info.plist에서 편집 할 수 있습니다.

는 iOS6

:

- (BOOL)shouldAutorotate; 
- supportedInterfaceOrientations; 

iOS5를 들면 : 또한, 이는 다음 방법 재정의 특정 controlelr 지정할 수있다 전체 화면으로 영상을 늘 keywindow 채우기 프레임을 설정

- (BOOL)shouldAutorotateToInterfaceOrientation: 
+0

을 :(I은 여전히 내비게이션 막대를 참조하십시오 – DanielR

+0

UIImageView 여전히 내 UITableView 위에 있지만 NavigationControllerView 뒤에있는 것 같아 – DanielR

+0

당신은 확실히 keyWindow에 imageView를 추가 했습니까? 그렇다면 [keyWindow bringSubviewToFront : imageView];를 호출 해보십시오 – Mikhail