我正在使用带有滑块(m_CrtlSliderRating) 和标签(m_CtrlLabelpositonName) 的自定义表视图单元。我需要根据更改的滑块值更改标签的文本。以下是我尝试过的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustumCell_GroupSlider *cell = (CustumCell_GroupSlider *) [tableView dequeueReusableCellWithIdentifier:@"cellA"];
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustumCell_GroupSlider" owner:Nil options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (CustumCell_GroupSlider *) currentObject;
break;
}
}
}
cell.accessoryType = UITableViewCellAccessoryNone;
cell.m_CtllabelHeading.text =[ NSString stringWithFormat:@"%@", ObjIQuestions.m_strTitleEn];
cell.m_CtrlLabelpositonName.tag=indexPath.row;
cell.m_CrtlSliderRating.tag=indexPath.row;
cell.m_CrtlSliderRating.minimumValue = 0.0;
cell.m_CrtlSliderRating.maximumValue = (ObjIQuestions.m_muteArrOptions.count-1)*5;
[cell.m_CrtlSliderRating addTarget:self
action:@selector(GroupsliderValueChanged:)
forControlEvents:UIControlEventValueChanged];
}
-(void)GroupsliderValueChanged:(id)sender
{
UISlider *ObjSlider = (UISlider *)sender;
//How can i change the label value here i tried something but got error
}
下面是自定义类接口
@interface CustumCell_GroupSlider : UITableViewCell
{
__weak IBOutlet UISlider *m_CrtlSliderRating;
__weak IBOutlet UILabel *m_CtllabelHeading;
__weak IBOutlet UILabel *m_CtrlLabelpositonName;
}
@property (weak, nonatomic) IBOutlet UILabel *m_CtllabelHeading;
@property (weak, nonatomic) IBOutlet UISlider *m_CrtlSliderRating;
@property (weak, nonatomic) IBOutlet UILabel *m_CtrlLabelpositonName;
如果有人有这方面的经验,请帮助我。