开发者

How can I shift table cells and make an image appear?

When the user presses the "Download" button, I want all the cells in the table 开发者_StackOverflow社区to shift to the right side, and correspondingly an image be displayed on the left side.

How can I accomplish this?


I think the fastest way is changing the way the data source behaves for your table. When you build the table you do it in the common way. When you click on the button, you update the data source flagging a boolean variable into it to the YES value, then in the tableView:cellForRowAtIndexPath: method, if flag == YES you can add a image to the cell.

If you rely on the standard cells, you can try this:

if (flag) {
    cell.imageView.image = [UIImage imageNamed:@"myImage.png"];
} else {
    cell.imageView.image = nil;
}

And at the end of the click event you should reload the table:

[self.tableView reloadData];

It's a quick and dirt solution, but should work fine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜