2011-11-08 2 views
15
  1. 스토리 보드 단을 사용하여 모달로 표시된 View Controller의 크기를 조정할 수있는 방법은 무엇입니까?ios5 - 스토리 보드가있는 모달 뷰 컨트롤러의 크기

  2. 플립 전환 기능이있는이 모달보기 컨트롤러에서 다른보기 컨트롤러를 어떻게 표시합니까?

스타일 = 모달, 프레젠테이션 = 기본값, 전환 = 뒤집기 수평으로 정의하면 이상하게 보입니다 (배경이 흰색 임).

Thx!

+3

주, 당신은 거의 항상 modalViewController가 먹고 싶어 전체 화면. 이것은, modalViewController가 출현하면 (자), modalViewController의 「아래」에있는 viewController가 삭제 되었기 때문입니다. 따라서 다른 viewController가 "밑에"보이도록하려는 의도로 modalViewController로 화면의 절반을 덮으려고하면이 작업이 수행되지 않습니다. 흰색으로 표시됩니다. 부모보기의 하위보기로보기를 추가하여이 기능을 수행합니다. – bearMountain

+0

귀하의 의견은 프레임 워크의 동작면에서 정확할 수 있습니다. 그러나 UI 프레임 워크의 기본 인터 워킹이 아닌 앱의 UX와 사용자에게 가장 적합한 것이 무엇인지를 분명히 원하는 "확실한"것이어야합니다. UI가 사용자 정의 대화 상자 내부에 모달 UI를 표시하도록 지시 할 수 있습니다.이 경우 사용자는 대화 상자의 내용을 계속 볼 필요가 있습니다. 커스텀 segue 및 unwind segue는 필요에 따라 수동으로 대화 상자 하위보기 (어둡게하기, 대화 내용)를 추가/제거하여 이전 컨트롤러의보기를 제거하지 않고도 쉽게 처리 할 수 ​​있습니다. – Marchy

+0

http : // stackoverflow에서 작동하는 해결책이 있습니다.com/questions/25250510/set-size-of-iphone-view-controller/25251507 # 25251507 –

답변

34

예. 인터페이스 빌더에서 뷰 컨트롤러를 선택하고 속성 관리자에서 Size를 freeform (유추로부터)으로 설정합니다. 그런 다음 뷰를 선택하고 측정 값을 원하는 값으로 설정하십시오. 주목할 중요한 점은 View Controller에서 View NIB From Resize의 선택을 취소하면 뷰가 전체 화면이됩니다.

배경이 유일한 문제인 경우 두 번째 질문에 대한 확신이 없습니까? 단지 색상을 설정할 수 없습니까?

희망이 도움이됩니다.

+4

적어도 저의 경우에는 작동하지 않습니다. 어떤 생각? 감사. – Ricardo

+8

+1 NIB에서보기 크기 조정 확인란을 언급하기 위해, 나는 결코 그렇지 않다는 것을 발견했을 것입니다. – DonnaLea

+0

당신은 남자 야 !!!! 정말 고맙습니다! –

1

나는 동일한 기능을 수행 할 노력하고있어 및 스토리 보드에 내 ModalView는 작지만, 시뮬레이터에 모든 화면을 커버 ...

나는했습니다 (...이 아이폰에서 수행 할 수 없다고 생각 iPad에서 간단한 테스트를 만들었고 모달 뷰가 작동했습니다.)

iPhone 용 반투명보기를 시도하고 모달보기를 사용하지 않습니다.

희망이 도움이됩니다.

5

사용자 지정 UIStoryboardSegue로 모달 표현보기의 크기를 조정할 수 있습니다. 스토리 보드에서 단조를 모달이 아닌 맞춤으로 설정하십시오. Segue 클래스에서 UIStoryboardSegue 재정의 이름을 지정하십시오.

UIStoryboardSegue를 덮어 쓰려면 .h 파일에 아무 것도 필요하지 않습니다. 그것은이 같은으로 나타납니다 :

MyStoryboardSegue.h :

#import <UIKit/UIKit.h> 
@interface MyStoryboardSegue : UIStoryboardSegue 
@end 

MyStoryboardSegue.m에서, 코드는 다음과 같습니다

#import "MyStoryboardSegue.h" 

@implementation MyStoryboardSegue 


- (void)perform 
{ 
    id sourceController = self.sourceViewController; 
    id destinationController = self.destinationViewController; 
    UIView *destinationView = [destinationController view]; 
    CGFloat x, y, w, h; 

    [destinationController setModalPresentationStyle:UIModalPresentationFormSheet]; 
    [destinationController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; 
    [sourceController presentViewController:destinationController animated:YES completion:nil]; 

/* 
You have to present the view first, and then resize it. That's because, 
as far as I can tell, when you present your view modally, a new view is created 
that covers the screen in a black semi-transparent mask to give the shadow effect, 
and a container view is placed in the middle of this view that in turn holds the 
view you are presenting. Your view automatically resizes to the size of this 
container view, so that's the view you need to resize to make your view controller 
appear the size you desire. You must present your modal view first 
because until you do, the container view doesn't exist. The following code 
resizes the container view (which is now your modal view's superview) and then 
resets the position of the container view to the center of the source view that 
is presenting the modal view so everything looks nice and centered. 
*/ 
    x = destinationView.superview.frame.origin.x; 
    y = destinationView.superview.frame.origin.y; 
    w = 400; // Your desired modal view width 
    h = 400; // Your desired modal view height 
    destinationView.superview.frame = CGRectMake(x, y, w, h); 
    destinationView.superview.center = [[sourceController view] center]; 
} 

@end 
+0

나는 이것을 Xcode 5에서 UINavigationController 내부에서 처리했다. (문제가된다면) 뭔가 빠져 있지 않으면 작동하지 않는 것 같다. –