gpt4 book ai didi

ios - convertPoint :fromView: works well on the simulator, 不在设备上

转载 作者:行者123 更新时间:2023-11-28 18:02:32 24 4
gpt4 key购买 nike

我很高兴看到这个:answer for how to convert point of a subview它在模拟器上非常适合我。

但由于某种原因,它在设备上不起作用...会不会是设备对 View 位置进行了不同的管理——或者这只是另一个谜?或者(希望)我写错了,你们可以帮忙......:)

这是我的台词:

CGPoint yoel = [imagePressed.imageView convertPoint:imagePressed.frame.origin toView:nil];

最佳答案

我有一个与此问题相关的不同问题,并且注意到在转换矩形时我必须考虑屏幕的比例。 (即它在模拟器上工作不是因为它是模拟器,而是因为模拟器处于非视网膜模式)

// the following convertRect is like asking a view: "what would one of your subviews (aView) have for a frame in my (toView) coordinate space if it were to become my subview?
_originalFrame = [[aView superview] convertRect: aView.frame toView: self];

CGFloat scale = [[UIScreen mainScreen] scale];

_originalFrame.origin.x /= scale;
_originalFrame.origin.y /= scale;
_originalFrame.size.width /= scale;
_originalFrame.size.height /= scale;

NSLog(@"Converted Frame: %@", NSStringFromCGRect(_originalFrame));

关于ios - convertPoint :fromView: works well on the simulator, 不在设备上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6013766/

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