Ios UIAlertController popoverPresentationController覆盖sourceView
我正在为Ios UIAlertController popoverPresentationController覆盖sourceView,ios,ipad,uialertcontroller,Ios,Ipad,Uialertcontroller,我正在为UIAlertController设置属性,如下所示: alertController.modalPresentationStyle = .popover alertController.popoverPresentationController?.sourceView = sourceView alertController.popoverPresentationController?.sourceRect = sourceView.bounds 在iPad上显示此alertCont
UIAlertController
设置属性,如下所示:
alertController.modalPresentationStyle = .popover
alertController.popoverPresentationController?.sourceView = sourceView
alertController.popoverPresentationController?.sourceRect = sourceView.bounds
在iPad上显示此alertController
时,会按预期显示一个popover,popover箭头尖端位于sourceView
的正中央。但是,这掩盖了mysourceView
的部分内容。我能做些什么来避免内容被覆盖吗?例如,如果箭头指向下方,则箭头尖将位于mysourceView
的顶部。如果箭头指向上,则箭头尖将位于我的源代码视图的底部。我可以操作sourceRect
,但我无法提前知道箭头方向是什么。相对于sourceView,箭头应该指向sourceRect的外部。当您将sourceView.bounds指定为应该是整个源代码视图的sourceRect时。所以不应该重叠
在其中设置一个断点,然后单步执行并验证一切是否如预期的那样。相对于sourceView,箭头应指向sourceRect的外部。当您将sourceView.bounds指定为应该是整个源代码视图的sourceRect时。所以不应该重叠
在那里设置一个断点,然后逐步检查并验证一切是否符合预期。@Ben William我也尝试了同样的方法,但我的警报显示在sourceView的范围之外。你完全正确。这个问题在我的代码中的其他地方。谢谢@Ben William我也尝试了同样的方法,我的警报显示在sourceView的范围之外。你完全正确。这个问题在我的代码中的其他地方。谢谢