-1
我幾乎是新來創建自定義單元格。我有一個自定義單元格,並在每行上用自定義按鈕創建了6個標籤(btnEdit
)。自定義按鈕被從.xib
中刪除。 btnEdit
在兩個標籤上創建一個框架,如果該框架被點擊,它會調用另一個正常工作的功能。如何從單元格中刪除所有標籤圖層
我唯一的問題是,如果我點擊行中的一個btnEdit
,我不希望它在另一行中被點擊,除非它被刪除,或者如果一個被選中,另一個被點擊則刪除首先和框架另一個。
這是我的代碼,我希望它有幫助;
.H
@interface PositionTableCell : UITableViewCell {
IBOutlet UILabel *lblSymbol;
IBOutlet UILabel *lblSpl;
IBOutlet UILabel *lblLpl;
IBOutlet UILabel *lblrate;
IBOutlet UILabel *lblAmount;
IBOutlet UILabel *lblO;
}
@property (nonatomic, assign) BOOL isSelected;
@property (nonatomic, assign) BOOL isRowSelected;
@end
.M
- (IBAction)btnEdit:(id)sender
{
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(value1)];
tapGestureRecognizer.numberOfTapsRequired = 1;
[lblLpl addGestureRecognizer:tapGestureRecognizer];
UITapGestureRecognizer *tapGestureRecognizer2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(value2)];
tapGestureRecognizer2.numberOfTapsRequired = 1;
[lblSpl addGestureRecognizer:tapGestureRecognizer2];
if (!isSelected){
lblLpl.layer.borderColor = lblSpl.layer.borderColor = [UIColor blueColor].CGColor;
lblLpl.layer.borderWidth = lblSpl.layer.borderWidth = 5.0;
lblLpl.userInteractionEnabled = lblSpl.userInteractionEnabled= YES;
isRowSelected = YES;
isSelected = YES;
}
else if (isSelected){
lblLpl.layer.borderColor = lblSpl.layer.borderColor = [UIColor clearColor].CGColor;
lblLpl.layer.borderWidth = lblSpl.layer.borderWidth = 0;
lblLpl.userInteractionEnabled = lblSpl.userInteractionEnabled= NO;
isRowSelected = NO;
isSelected = NO;
}
[tapGestureRecognizer release];
[tapGestureRecognizer2 release];
NSLog(@"CLICKED");
}