gpt4 book ai didi

iphone - 将 UIImage 添加到 UITableViewCell "State Touched"

转载 作者:行者123 更新时间:2023-12-03 21:10:28 27 4
gpt4 key购买 nike

UITableViewCell 中添加触摸状态图像的最佳方法是什么?

我知道如何设置 cell.selectionStyle 但实际上我需要在用户触摸它时添加一个图像(每行不同的图像)(并且它将新 View 推送到)就像“触摸按钮状态”。

实现这一目标的最佳方法是什么?我尝试过

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { }

或者我必须在里面做

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

谢谢!

最佳答案

我建议您创建自定义 UITableViewCell 并使用 touchesBegantouchesEnded

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchedBegan:touched withEvent:event];
// ... display image 2, hide image 1
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchedEnded:touched withEvent:event];
// ... display image 1, hide image 2
}

关于iphone - 将 UIImage 添加到 UITableViewCell "State Touched",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3628366/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com