2016-03-28 65 views
2

ボタンの下またはウインドウの中央にUIPopoverPresentationControllerとして表示コントローラを表示しようとしています。しかし、常にフルウィンドウのモーダルポップアップとして表示されます。UIPopoverPresentationController全画面モーダルポップアップを常に表示

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    MySecondViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"Pop"]; 

    // present the controller 
    // on iPad, this will be a Popover 
    // on iPhone, this will be an action sheet 
    controller.modalPresentationStyle = UINavigationControllerOperationPop; 
    [self presentViewController:controller animated:YES completion:nil]; 
    controller.preferredContentSize = CGSizeMake(280, 230); 
    // configure the Popover presentation controller 
    UIPopoverPresentationController *popController = [controller popoverPresentationController]; 
    popController.permittedArrowDirections = UIPopoverArrowDirectionUp; 
    popController.delegate = self; 

    // in case we don't have a bar button as reference 
    popController.sourceView = self.showPop; 
    popController.sourceRect = CGRectMake(384, -120, 280, 230); 


-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller { 
    return UIModalPresentationNone; 
} 

答えて

3

それは私が同じ質問に対して別の質問を掲載していると私は私の問題を解決した

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
SecondViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"pop"]; 

controller.modalPresentationStyle = UIModalPresentationPopover; 
controller.preferredContentSize = CGSizeMake(280, 230); 
// configure the Popover presentation controller 

controller.popoverPresentationController.delegate = self; 
controller.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp; 


// in case we don't have a bar button as reference 
controller.popoverPresentationController.sourceView = self.view; 
controller.popoverPresentationController.sourceRect = CGRectMake(384, -120, 280, 230); 
// controller.presentationController.delegate = self; 
[self presentViewController:controller animated:YES completion:nil]; 
+0

私はバーのボタンを使用するつもりです...それはフルスクリーンで私をtablewiew示しています...私はハッサンアフタブ –

+0

@SurajSukale @ ...何をすべき、それは、あなたのために遅すぎるかもしれませんおそらく誰かがこのコメントから利益を得ることができます。デリゲートをcontroller.popoverPresentationControllerに代入し、デリゲートで 'adaptivePresentationStyle(for:UIPresentationController)'を実装し、 'UIModalPresentationStyleNone'という値を返します。 – Lukas1

2

を働いているこのコードを試してみてください。ここに質問のリンクがあります: UIPopoverPresentationController is showing full screen modal on iPhone

In ViewController.h最初にUIPopoverPresenatationControllerのプロパティを作成します。その後PopOverPresentationcontroller

UINavigationController *destNav = [[UINavigationController alloc] initWithRootViewController:dateVC]; 
/*Here dateVC is controller you want to show in popover*/ 
       dateVC.preferredContentSize = CGSizeMake(280,200); 
       destNav.modalPresentationStyle = UIModalPresentationPopover; 
       _dateTimePopover8 = destNav.popoverPresentationController; 
       _dateTimePopover8.delegate = self; 
       _dateTimePopover8.sourceView = self.view; 
       _dateTimePopover8.sourceRect = [sender frame]; 
       destNav.modalPresentationStyle = UIModalPresentationPopover; 
       destNav.navigationBarHidden = YES; 
       [self presentViewController:destNav animated:YES completion:nil]; 

を表示する

@property(nonatomic,retain)UIPopoverPresentationController *dateTimePopover8; 

あなたは私たちがクリックしたときにalso.Itが自動的に非表示になり、新たな方法でこれを非表示にする必要があり、我々はビューコントローラを提示する代わりにpopOver.Soを提示していることに気づいている必要があります画面上で。

-(void)hideIOS8PopOver 
{ 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

私たちは、実装ファイルでのデリゲートメソッド以下の実施file.WriteにUIPopoverPresenatationControllerのデリゲートを実装する必要があります。

- (UIModalPresentationStyle) adaptivePresentationStyleForPresentationController: (UIPresentationController *) controller { 
    return UIModalPresentationNone; 
} 
0

これは非常に簡単です。ストーリーボードビューコントローラー(ナビゲーションコントローラーのルートビューでナビゲーションコントローラーにドラッグした場合)にアクション(たとえばUIBarButtonまたは通常のボタン)をトリガーするコントロールからドラッグを制御するだけです。 セグを選択し、属性インスペクタの種類を「現在のモーダル」に変更します。プレゼンテーション:フォームシート(中央に表示したい場合)で、必要なトランジションタイプ(デフォルトはクール)を選択します。

Attribute Inspector screenshot

関連する問題