获取 UITableViewCellAccessoryType 的框架 [英] Get frame for UITableViewCellAccessoryType

查看:18
本文介绍了获取 UITableViewCellAccessoryType 的框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想展示一个弹出框.目前我可以检索整个单元格的框架(如此处所述).是否可以获取附件的框架(UITableViewCellAccessoryType)?

I want to present a popover. Currently I can retrieve the frame of the whole cell (as described here). Is it possible to get the frame of the accessory (UITableViewCellAccessoryType)?

我想检索 accessoryButtonTappedForRowWithIndexPathdidSelectRowAtIndexPath 中的值.

I want to retrieve the value in accessoryButtonTappedForRowWithIndexPath or didSelectRowAtIndexPath.

推荐答案

我能想到的最好办法是计算具有固定尺寸的框架.首先,您使用 rectForRowAtIndexPath 获得单元格的框架.比你计算 accessoryType 框架.就我而言,我可以提供 C# 代码,但您可以轻松将其转换为 Objective-C 或推出您自己的解决方案:

The best I can come up with is to calculate the frame with fixed sizes. First you get the cell's frame with rectForRowAtIndexPath. Than you calculate the accessoryType frame. In my case I can give C# code, but you can translate it to Objective-C easily or roll your own solution:

int detailDisclosureSize = 24;
RectangleF accessoryPosition = new RectangleF(cellPosition.X + cellPosition.Width - detailDisclosureSize * 2.45f, cellPosition.Y + cellPosition.Height/2 - detailDisclosureSize/2, detailDisclosureSize, detailDisclosureSize);

cellPositionrectForRowAtIndexPath 的结果.现在您可以使用 convertRect:toView: 将其转换为真实坐标.

cellPosition is the result from rectForRowAtIndexPath. Now you can translate it to the real coordinates with convertRect:toView:.

但如果出现新的屏幕尺寸,该解决方案将不起作用.由于目前没有其他解决方案,我将使用这个或整个单元格大小.

But the solution won't work if a new screen size comes out. Since there is currently no other solution I'll go with this or the whole cell size.

这篇关于获取 UITableViewCellAccessoryType 的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆