UITableView中的一行中有两个单元格 [英] Two cells in one row in UITableView

查看:61
本文介绍了UITableView中的一行中有两个单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Twitter应用程序(以前的Tweetie应用程序)的用户详细信息中构建一个类似于用户详细信息中的表格的UITableView单元格.

I'm trying to build a grouped UITableView cell like the table in user details in Twitter's app (former Tweetie app).

这是一个具有两个侧面的单元格,您可以分别选择它们中的任意一个(背景变成蓝色,就像一个圆形的按钮一样.)

It's a cell with two sides, and you can select any of them separately (and the background turns blue, like a rounded button).

有人做过类似的事情,还是知道他们是怎么做的?

Anyone did something like it or know how they made it?

视图中的屏幕截图(以下是tweet,关注者和收藏夹单元格

A screen shot from the view (it's the following, tweets, followers and favorites cells)

推荐答案

我想在自己的应用程序中执行相同的操作,但对于在Twitter应用程序中如何完成操作,我还是一无所知.

I was wanting to do the same in my own app, but I was also a bit clueless on how this was done in the Twitter app.

在Twitter应用程序中与该单元格进行了长时间的互动之后,尝试将其打破以查看其功能(例如,同时按下多个按钮,在点击时滚动等XD),我想弄清楚了怎么做.

After having a long play with that cell in the Twitter app, trying to break it to see what it'd do (eg, pressing multiple buttons at the same time, scrolling while tapping etc XD), I think I've figured out how it's done.

据我所见,它是一个UITableViewCell(即跨越多行),其中添加了特殊的自定义contentView,可呈现其中的所有内容(文本,行等).当用户点击该单元格时,自定义视图会计算出整个单元格的哪个区域被轻敲(可以通过截取自定义视图类中的touchesBegan来实现),然后重绘该特定区域,使其突出显示(可能完全在drawRect中).

From what I can see, it's a single UITableViewCell (ie spanning multiple lines) with a special custom contentView added into it that renders everything in there (text, lines etc). When a user taps the cell, the custom view works out which region of the overall cell was tapped (Possible by intercepting touchesBegan in the custom view class), and then redraws that particular region as highlighted (probably entirely within drawRect).

因为如果您非常仔细地看,高亮的蓝色背景会稍微重叠单元格的弯曲角(表示它在顶部绘制),所以我猜是自定义单元格也亲自呈现了突出显示的蓝色背景(与UITableViewCell相对照常进行操作.)

Since if you look VERY closely, the highligthed blue background overlaps the cell curved corner slightly (denoting it's being drawn over the top), my guess is the custom cell is also personally rendering the highlighted blue background (As opposed to the UITableViewCell doing it as per usually).

希望能有所帮助.这不是一个非常优雅的解决方案,但希望可以解决问题.

Hope that helped. It's not a very elegant solution, but it should hopefully do the trick.

这篇关于UITableView中的一行中有两个单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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