开发者

Adding a subview to a TableViewCell

I am trying to write a simple TableView which does the following:

If the user presses a button located on the 开发者_如何学编程left of the cell, a subview will pop-up over the button. The subview will have a larger height than the TableViewCell, and will have a button on it which when pushed pops the subview.

I am having difficulty adding the subview to the cell. I am wondering if I am going about this all wrong, and should maybe just be adding the subview on top of the tableView, rather than having the cell try to do it.

Any suggestions? Thanks in advance!


From your description I guess you want a custom UITableViewCell with a UIControl at the left as a subview. Pressing the UIControl should animate a different subview on top of the current cell.

That's fine, but if you are having trouble with it, post the details or do some research on custom UITableViewControllers and UITableViewCells. This may help: Fast Scrolling in Tweetie with UITableView, UITableView construction, drawing and management (revisited). Not only is on the way of what you are trying to achieve, it will also improve the performance of your tables.

This project is an alternate way to achieve what you are trying to do: https://github.com/thermogl/TISwipeableTableView/tree/master/SwipeableExample it lets you swipe back and forth the current cell to reveal a different view.


It's hard to tell exactly what's wrong without seeing some code, but the first thing I'd suggest is to make sure you're adding the subview to the cell's contentView.


you need to do [cell.contentView addSubview:view].

Bear in mind though that I highly suggest subclassing UITableViewCell for this.


I suggest you to use UITableviewCell for cell customization. Refer this link http://iphonesdevsdk.blogspot.com/2011/04/custom-tableview.html

it may help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜