如问题所述,我想获得图像中显示的 uibutton 的位置,并且我必须显示该 uibutton 的弹出菜单(在 tableviews View 中)。
我经历了Question1和 Question2 .但是这些给了我不同的位置。
我用代码
CGRect windowRect = [_tableView convertRect:button.frame fromView:tempCell];
临时单元格是我选择的单元格。
我正在使用 kxMenu 作为弹出菜单,我使用以下代码。
[KxMenu showMenuInView:_tableView
fromRect:windowRect
menuItems:menuItems];
所以,我需要正确获取 windowRect。有人知道吗?
最佳答案
如果你使用
[_tableView convertRect:button.frame fromView:tempCell];
它会将按钮的帧 wrt tempcell 转换为按钮帧 wrt _tableView
如果你想在窗口中获取按钮的框架,你应该做任何一个
[button convertRect:button.bounds toView:nil];
或
[button.superView convertRect:button.frame toView:nil];
关于ios - 如何获取 uibutton(UITableViewCell 的 subview )相对于整个窗口 iOS objective-C 的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33914943/