2013-05-08 113 views
0

我正在使用帶滑塊(m_CrtlSliderRating)和標籤(m_CtrlLabelpositonName)的custum tableviewcell。我需要改變關於slidervalue changed.Below標籤的文字是什麼,我試圖用uislider更改自定義tableview單元格標籤的值

- (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; 

請幫助我,如果任何人有經驗,它。

+0

你能給我CustumCell_GroupSlider的屏幕油粕並在其中標明你想chnages – 2013-05-08 10:39:58

回答

0

你有一個自定義單元格,那麼爲什麼不放置

-(void)GroupsliderValueChanged:(id)sender 
{ 
    // --- 
    m_CtrlLabelpositonName.text = [NSString stringWithFormat:@"%f", m_CrtlSliderRating.value]; 
} 

在自定義單元格?還有你也訪問是由該小區:)

0
-(void)GroupsliderValueChanged:(UISlider)*sender 
{ 
    UITableViewCell *objCell = (UITableViewCell *)[yourTableView cellForRowAtIndexPath:sender.tag]; 
    objCell.m_CtllabelHeading.text = @"your text"; 

} 
0

使用固定標籤

-(void)GroupsliderValueChanged:(UISlider)*sender 
    { 
     CustumCell_GroupSlider *c = (CustumCell_GroupSlider *)[tableView cellForRowAtIndexPath:sender.tag] 
     c.m_CtllabelHeading.text = @"Slider Value";  
    } 
相關問題