3

私は画像でポップオーバーを表示する必要があるアプリを開発しています。私は UIPopoverController を使用しましたが、現在 iOS8 ではこのクラスは非推奨であり、Apple は代わりに UIPopoverPresentationController を使用することを提案していますが、ポップオーバーを表示しようとすると黒い画面が表示されます。手伝って頂けますか?ありがとう。

これは、「popVC」と呼ばれるView Controllerをポップオーバーとして開こうとするコードです。*vernazaImagenDetalle は UIViewController サブクラスです

vernazaImagenDetalle *vc =

[self.storyboard instantiateViewControllerWithIdentifier:@"popVC"];

vc.modalPresentationStyle = UIModalPresentationPopover;

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



UIButton *boton=(UIButton*)sender;

NSLog(@"tag %ld",(long)boton.tag);



UIPopoverPresentationController *presentationController =

[vc popoverPresentationController];

presentationController.permittedArrowDirections =0;

presentationController.sourceView =boton;

presentationController.sourceRect = CGRectMake(self.stringContenido.frame.size.width/2,(250+self.stringContenido.contentOffset.y),1,1);

vernazaImagenDetalle class.h vernazaImagenDetalle class.m

ストーリーボードの VC (メイン)

ボタンをクリックしてポップオーバーを表示したときの画面

4

1 に答える 1

0

私にとって、presentationControllerDelegateに以下を追加するとうまくいきました-

  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
    return .None;
  }
  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
    return .None;
  }
于 2016-07-11T14:01:11.777 に答える