1

UIModalPresentationPageSheet와 함께 표시하는 모달 뷰 컨트롤러가 있습니다. 문제는 기본 크기가 내 콘텐츠에 비해 너무 크다는 것입니다. 콘텐츠 크기에 따라 조정할 프레임 크기를 조정하고 싶습니다.UIModalPresentationPageSheet를 사용하여 modalViewController의 크기를 조절하는 방법

누구든지이 작업을 수행하는 방법을 알고 있습니까?

감사

UIModalPresentationFormSheet로 제시 것 뷰 컨트롤러의 크기를 조정 작동
+0

'UIModalPresentationFormSheet'에는 키보드 숨기기에 문제가 있습니다. 'UITextField'에서'resignFirstResponder'를 호출하면 키보드가 닫히지 않습니다. – Fry

+0

http://stackoverflow.com/a/4850751/2832188 – ManicMonkOnMac

답변

0

당신은 UIModalPresentationPageSheet 크기를 조정할 수 없습니다 : 나는 그것이 작동 여부 있을지 잘 모르겠어요이 시도를 줄 것이다.

+1

사실 UIModalPresentationPageSheet에 표시되고 슈퍼 뷰를 참조하여 크기를 변경하는 사용자 정의 뷰 컨트롤러를 사용하여 할 수 있습니다. 아래 예가 있습니다. – Hrafn

+0

잘 수행 할 수 있습니다. 여기를 확인하십시오. http://stackoverflow.com/a/4850751/2832188 – ManicMonkOnMac

-1

. 크기가 modifable하지 않기 때문에

navController.modalPresentationStyle = UIModalPresentationFormSheet; 
[self presentModalViewController:navController animated:YES]; 
//these two lines are if you want to make your view smaller than the standard modal view controller size 
navController.view.superview.frame = CGRectMake(0, 0, 200, 200); 
navController.view.superview.center = self.view.center; 
+0

이 작동하지 않습니다. 내 게시물에서 내가 설명하고 싶지 않아 어떤 이유로 사용자 정의 프레임과 PageSheet를 사용해야한다고 말했다. FormSheet를 사용할 수 없습니다. – Fry

6

실제로 UIModalPresentationPageSheet로 표시되는보기 컨트롤러의 크기를 조정할 수 있습니다.

<!--The header file--> 
@interface MyViewController: ViewController{ 
    //Used to store the bounds of the viewController 
    CGRect realBounds; 
} 

<!--In the .m file--> 

//viewDidLoad gets called before viewWillAppear, so we make our changes here 
-(void)viewDidLoad{ 
    //Here you can modify the new frame as you like. Multiply the 
    //values or add/subtract to change the size of the viewController. 
    CGRect newFrame = CGRectMake(self.view.frame.origin.x, 
           self.view.frame.origin.y,  
           self.view.frame.size.width, 
           self.view.frame.size.height); 

    [self.view setFrame:newFrame]; 

    //Now the bounds have changed so we save them to be used later on 
    _realBounds = self.view.bounds; 

    [super viewDidLoad]; 
} 

//viewWillAppear gets called after viewDidLoad so we use the changes 
//implemented above here 
-(void)viewWillAppear:(BOOL)animated{ 

    //UIModalpresentationPageSheet is the superview and we change 
    //its bounds here to match the UIViewController view's bounds. 
    [super viewWillAppear:animated]; 
    self.view.superview.bounds = realBounds; 

} 

을 그리고 당신은 UIModalPresentationPageSheet이 뷰 컨트롤러를 표시 : 그것을 위해 당신은 클래스에 다음과 같은 사용자 정의 뷰 컨트롤러 클래스를 생성하고 추가해야합니다. 그리고 그게 다야. 이 게시물은 iOS 5.1.1 및 iOS 6에서 작동합니다.

+0

이 답변은 정말 대단합니다. 이 똑같은 것이 필요하기 때문에 포스터의 질문을 이해합니다. 그것은 작동합니다. 이것은 승인 된 대답이어야합니다. –

+1

이 답변은 훌륭한 시작이지만 사용자 정의 크기의 formview를 중앙에 배치하는 방법이없는 것 같아 매우 제한됩니다. 다양한 뷰와 수퍼 뷰의 중심에 원하는 효과가 없습니다. – memmons

관련 문제