カスタムセルにボタンがあるテーブルがあります。このボタンを押すと、次のコードを使用してボタンを検出するメソッドが呼び出されます。
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 送信者を直接使用することはできません。というか、使用したくありません。
コードは正しいようです
ありがとう!