这有时是这样的:
我想在圆圈中显示一个视图控制器,但是,几乎每次呈现圆圈中的视图控制器(ResultVIEwController)时,它的位置都不同,尽管它的属性根本不会改变.这是我的代码:
func openCircle(withCenter center: CGPoint,dataSource: ([Items],Int,String)){ self.addCircle(withCenter: center,dataSource: dataSource)}func addCircle(withCenter circleCenter: CGPoint,String)) { let longerSIDe = fmax(vIEw.frame.size.height,vIEw.frame.size.wIDth) let shorterSIDe = fmin(vIEw.frame.size.height,vIEw.frame.size.wIDth) let circleRadius = longerSIDe / 2 var resultVIEwOrigin = CGPoint() var resultVIEwSize = CGSize() if UIDevice.current.userInterfaceIdiom == .pad { let rectWIDth = shorterSIDe / 2 let rectHeight = sqrt(abs(circleRadius * circleRadius - rectWIDth * rectWIDth)) + vIEw.frame.size.height - circleCenter.y resultVIEwSize = CGSize(wIDth: rectWIDth,height: rectHeight) resultVIEwOrigin = CGPoint(x: (vIEw.frame.size.wIDth - rectWIDth) / 2,y: vIEw.frame.size.height - rectHeight) } else { resultVIEwOrigin = CGPoint(x: 0.0,y: 0.0) resultVIEwSize = CGSize(wIDth: vIEw.frame.size.wIDth,height: vIEw.frame.size.height) } let resultVIEwController = UIStoryboard(name: "Main",bundle: Bundle.main).instantiateVIEwController(withIDentifIEr: "ResultVC") as! ResultVIEwController resultVIEwController.TransitioningDelegate = self resultVIEwController.modalPresentationStyle = .custom resultVIEwController.dataSource = dataSource resultVIEwController.vIEw.frame = CGRect(origin: resultVIEwOrigin,size: resultVIEwSize) Transition.circle = UIVIEw() Transition.startingPoint = circleCenter Transition.radius = circleRadius Transition.circle.frame = circleFrame(radius: Transition.radius,center: Transition.startingPoint) present(resultVIEwController,animated: true)}
它在iPhone上运行良好,而不是在iPad上运行,问题是什么?
解决方法 我发现了这个问题,它实际上是一个缺少常规 – 常规尺寸类的约束引起了这个问题,我通过在底部布局指南中添加一个间距来修复它,这个部分曾经被错放了.感谢大家的想法.
总结以上是内存溢出为你收集整理的ios – 每次显示控制器原点时都会发生变化全部内容,希望文章能够帮你解决ios – 每次显示控制器原点时都会发生变化所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)