2011-08-23 1 views
1

설명을 표시하기 위해 UIscrollview에 UIWebviews를 추가 한 프로젝트에서 작업하고 있습니다. 스 와이프 효과를 추가하여 새 설명 페이지로 이동하기 때문에이 작업을 수행했습니다. 이제 UIscrollview와 그 내용 (즉, uiwebview)의 방향이 바뀌면 (즉 세로에서 가로로 또는 Viceversa로) 크기를 조정하려고합니다.iPhone에서 방향 변경시 uiscrollview 및 해당 내용의 크기를 조정하는 방법은 무엇입니까?

샘플 코드 나 제안 사항을 알려주십시오.

답변

0

다음과 같은 코드 블록에 코드를 넣을 수 있습니다 :

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
if ([self isPadPortrait]) { 
    // Your code for Portrait 
    // set frame here 
} else if ([self isPadLandscape]) { 
    // Your code for Landscape 
    // set frame here 
} 

코드를 다음은 방향 변경 처리 소요됩니다 : 당신은있는 ScrollView의 autoresizingMask을 설정하고이 코드를 추가 할 수 있습니다

- (BOOL)isPadPortrait 
{ 

    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad 
      && (self.interfaceOrientation == UIInterfaceOrientationPortrait 
       || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)); 
} 

- (BOOL)isPadLandscape 
{ 

    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad 
      && (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight 
       || self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft)); 

} 
+0

감사합니다 - : –

+0

프레임을'willAnimateRotationToInterfaceOrientation :'에 설정할 수 있습니다. 또 뭐가 필요하니? – Devang

+0

나는 나와 함께 스크롤보기 만 있고 내용의 크기를 변경하려고합니다. 그렇게하는 방법? –

0

을 귀하의 요구 사항에 따라 귀하의 .m 파일.

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * someValue1, 
             scrollView.frame.size.height * someValue2); 
} 
+0

uiscrollview의 내용 인 uiwebview의 크기가 조정됩니까 –

+0

xib 파일에서 뷰를 만드는 경우 뷰를 회전하여 테스트 할 수 있습니다. 그렇지 않으면 덤프 xib 파일을 만들어 자신에게 필요한 자동 크기 지정 마스크를 확인해야합니다 응용 프로그램 – Robin

1

방향, 예를 들어

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration 

{ 

// this delegate method will called if we set should auto orientation return yes; 
when ever we changed orientation so set frames.. 

} 

을 변경 이제까지

다음
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration 

{ 
    appDelegate.interface=interfaceOrientation; 


    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) 

{ 

// SET FRAMES FOR LANDSCAPE HERE  


} 

    if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation == UIInterfaceOrientationPortrait) 

{ 
     //SET FRAMES FOR Portrait HERE    

} 

} 
0

이 비슷한 질문과 솔루션에 대한 링크입니다 : Scale image to fit screen on iPhone rotation

그들은 조합을 사용가 S와 AutodizingMasks 및 ContentModes에 대한 같은 솔루션이 당신의 WebView에서 작동한다고 생각 하긴하지만, crollView와, 그들의 경우 ImageView가 있습니다. 그것을 위해

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    webview.scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * someValue1, 
             scrollView.frame.size.height * someValue2); 
} 
1

당신이 쓸 수있는 웹보기의 크기를 조정합니다. 오리엔테이션을 감지 할 수 있습니다. 그러나 문제는 UIscrollview 및 해당 내용의 크기를 조정하는 것입니다. Plz 날 도와 줘.
+0

정확히 내가이 분야에 대한 새로운 오전,하지만 당신이 주된 @ shweta – SagarPPanchal

+0

좋은 일을, @ shweta에 값을 반환합니다 후 void를 사용하지 않으면 궁금해. :) – SagarPPanchal

관련 문제