UITableViewCell中单行选择

先来看两个方法

方法一:

tableView:didDeselectRowAtIndexPath:

Tells the delegate that the specified row is now deselected.

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath

Parameters

tableView

A table-view object informing the delegate about the row deselection.

indexPath

An index path locating the deselected row in tableView.

Discussion

The delegate handles row deselections in this method. It could, for example, remove the check-mark image (UITableViewCellAccessoryCheckmark) associated with the row.

方法二:

deselectRowAtIndexPath:animated:

Deselects a given row identified by index path, with an option to animate the deselection.

- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated

Parameters

indexPath

An index path identifying a row in the receiver.

animated

YES if you want to animate the deselection and NO if the change should be immediate.

Discussion

Calling this method does not cause the delegate to receive a tableView:willSelectRowAtIndexPath: or tableView:didSelectRowAtIndexPath: message, nor will it send UITableViewSelectionDidChangeNotification notifications to observers.


我的代码中有一行这样的代码

[tableView deselectRowAtIndexPath:indexPath animated:NO];

这直接导致我今天晚上,少睡了半个小时。由于我收不到tableView:didDeselectRowAtIndexPath消息,所以行选择取消,就没有被invoke。

睡觉了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值