0
我有一個表,其中有一個按鈕到定製細胞。當我按下此按鈕時,它會調用一個方法來檢測使用此代碼的按鈕:檢測從自定義小區的按鈕和改變的屬性
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發送者,或者說,我不喜歡使用它。
該代碼似乎正確
謝謝!
你能確保indexPath是正確的?將您想要更改的按鈕設置爲PlaceRoomCustomCell類中的屬性如何設置? –
indexpath是正確的:它是indexpath.row。 – Vins
我的意思是說:標籤是indexpath.row – Vins