2014-10-19 2 views
1

에서 나는 코드에서 내 UIPopoverPresentationController을 초기화하는거야 :UIPopoverPresentationController 스토리 보드

ChoseOptionsViewController *contentController = [[ChoseOptionsViewController alloc] init]; 
contentController.modalPresentationStyle = UIModalPresentationPopover; 
UIPopoverPresentationController *copvc = contentController.popoverPresentationController; 
copvc.permittedArrowDirections = UIPopoverArrowDirectionAny; 
copvc.sourceView = sender; 
copvc.sourceRect = sender.bounds; 
contentController.preferredContentSize = CGSizeMake(200, 200); 
[self presentViewController:contentController animated:YES completion:nil]; 

내가, 스토리 보드에서의 ViewController를 만들어 여기에 ChoseOptionsViewController 클래스를 할당했습니다 비록 내가 갖는 모든 빈 200x200 크기이다 일부 UI 요소를 드래그했습니다. 말해주십시오. 코드에서 팝업을 초기화 할 때 스토리 보드에서 내 의견을 얻으려면 어떻게해야합니까? 미리 감사드립니다.

답변

1

스토리 보드에서보기 컨트롤러를 만들 때 instantiateViewControllerWithIdentifier :를 사용하여 인스턴스를 만들고 init을 할당하지 않아야합니다.

ChoseOptionsViewController *contentController = [self.storyboard instantiateViewControllerWithIdentifier:@"Whatever"]; 

스토리 보드의 컨트롤러의 식별자가 메소드에 전달한 것과 동일한 문자열로 설정되어 있는지 확인하십시오.