2014-11-23 8 views
0

iPhone 응용 프로그램의 Alert Controller (경보 컨트롤러)와 같이 여러 항목이있는 버튼으로 성공적으로 구성된 탐색 모음의 제목에서 팝업을 표시하려고합니다. 다음 코드는 제목을 두드렸을 때 호출되지만 액션 시트가 팝 오버 대신 하단에 표시됩니다. 무엇이 잘못되었는지 찾도록 도와 줄 수 있습니까? 감사. 이 아이폰에 더 popoverPresentationController이 없습니다로iPhone OS 용 Popover에서 UIAlertController를 표시하는 방법 8

UIAlertController * alertController = [UIAlertController alertControllerWithTitle: nil 
                      message: nil 
                    preferredStyle: UIAlertControllerStyleActionSheet]; 
[alertController addAction: [UIAlertAction actionWithTitle:@"Close" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 
    // dismiss viewcontroller 
    [self dismissViewControllerAnimated:YES completion:nil]; 
}]]; 
[alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style: UIAlertActionStyleDefault handler:^(UIAlertAction *action) { 
    // Handle Cancel 
    // do nothing 
}]]; 

alertController.modalPresentationStyle = UIModalPresentationPopover; 
alertController.preferredContentSize = CGSizeMake(250.0, 180.0); 

UIPopoverPresentationController *popoverPresentation = alertController.popoverPresentationController; 
popoverPresentation.sourceRect = self.parentViewController.navigationItem.titleView.frame; 
popoverPresentation.sourceView = self.view; 
popoverPresentation.permittedArrowDirections = UIPopoverArrowDirectionUp; 
popoverPresentation.delegate = self; 

[self presentViewController: alertController animated: YES completion: nil]; 

답변

0

당신은 UIAlertController와 (프로그래밍) 코드로 할 수 없습니다. iPad에서만 사용할 수 있습니다.

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:PDFDataArray applicationActivities:nil]; 

if ([activityVC respondsToSelector:@selector(popoverPresentationController)]) { 
    NSLog(@"Popover available for this device type"); 
}  

나는 성공적으로 올바른 UIModalPresentationStyle을 반환 adaptivePresentationStyleForPresentationController 대리자 메서드를 인터페이스 빌더/스토리 보드에 적응 SEGUE 스타일 Present As Popover를 사용하여 구현, 과거에 아이폰에 popovers을 발표했습니다. 이 방법을 시도해 볼 수도 있습니다.