正如问题所说,我想获得图片中显示的uibutton的位置,我必须显示该uibutton的弹出菜单(在tableviews视图中)。
我经历了Question1和Question2。但这些给了我不同的位置。
我使用代码
CGRect windowRect = [_tableView convertRect:button.frame fromView:tempCell];
临时单元格是我选择的单元格。
我在popUp菜单中使用kxMenu,我使用以下代码。
[KxMenu showMenuInView:_tableView
fromRect:windowRect
menuItems:menuItems];
所以,我需要正确地获取windowRect。任何人都有任何想法?
答案 0 :(得分:2)
如果您使用
[_tableView convertRect:button.frame fromView:tempCell];
它会将按钮wrt tempcell的帧转换为按钮帧wrt _tableView
如果你想在窗口中获得按钮的框架,你应该做
[button convertRect:button.bounds toView:nil];
或
[button.superView convertRect:button.frame toView:nil];