我有一个表格,其中有一个自定义单元格的按钮。当我按下此按钮时,它会调用一个使用以下代码检测按钮的方法:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow: [[[notification userInfo] valueForKey:@"row"] intValue] inSection: 0];
PlaceRoomCustomCell *cell = (PlaceRoomCustomCell*)[self tableView:self.tableView cellForRowAtIndexPath:indexPath];
for (UIView *view in cell.contentView.subviews){
if (view.tag == 1) {
for (UIView *subview in view.subviews){
if ([subview isKindOfClass:[UIButton class]]){
[(UIButton *)subview setImage:[UIImage imageNamed:@"placeRoomTableCellLikeButtonRedIcon.png"] forState:UIControlStateNormal];
[(UIButton *)subview setImage:[UIImage imageNamed:@"placeRoomTableCellLikeButtonRedIcon.png"] forState:UIControlStateHighlighted];
[(UIButton *)subview setImage:[UIImage imageNamed:@"placeRoomTableCellLikeButtonRedIcon.png"] forState:UIControlStateDisabled];
NSLog(@"tag %i",subview.tag); //correct
}
}
}
}
标签是正确的,但图像没有改变。
我不能直接使用按钮的 id sender,或者更确切地说,我不想使用它。
代码似乎正确
谢谢你!