gpt4 book ai didi

objective-c - UIPopoverPresentationController 给我黑屏

转载 作者:搜寻专家 更新时间:2023-10-30 20:28:07 25 4
gpt4 key购买 nike

我正在开发一个需要用图像显示弹出窗口的应用程序,我使用了 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

The VC in the storyboard (Main)

the screen when i click the button to show the popover

最佳答案

对我来说,将以下内容添加到 presentationControllerDelegate 有效 -

  func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
return .None;
}
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return .None;
}

关于objective-c - UIPopoverPresentationController 给我黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26107897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com