Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 自定义表格视图单元格标签隐藏时滚动如何解决?_Iphone_Ios_Objective C_Ipad_Cocoa Touch - Fatal编程技术网

Iphone 自定义表格视图单元格标签隐藏时滚动如何解决?

Iphone 自定义表格视图单元格标签隐藏时滚动如何解决?,iphone,ios,objective-c,ipad,cocoa-touch,Iphone,Ios,Objective C,Ipad,Cocoa Touch,“我使用自定义单元格类来显示它成功显示的时间,但问题是,当我向下滚动表视图,然后计时器标签不显示。我使用了此代码,但当我向下滚动并再次向上滚动计时器隐藏的单元格标签时,我不知道如何解决此问题” //这里是迈塞尔类代码 - (void) startTimer:(NSIndexPath *)indexPath { if (self.timer) [self.timer invalidate]; currentIndexPath=indexPath; self.s

“我使用自定义单元格类来显示它成功显示的时间,但问题是,当我向下滚动表视图,然后计时器标签不显示。我使用了此代码,但当我向下滚动并再次向上滚动计时器隐藏的单元格标签时,我不知道如何解决此问题”

//这里是迈塞尔类代码

  - (void) startTimer:(NSIndexPath *)indexPath
   {


if (self.timer)

    [self.timer invalidate];


  currentIndexPath=indexPath;
   self.secondsLeft=10;


  self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self    selector:@selector(calculateTimer) userInfo:nil repeats:YES];

  [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];

   [self.timer fire];
 }

   - (void)calculateTimer
  {

if (self.secondsLeft >0)
{

    self.secondsLeft --;
    self.timeLbl.text=[NSString stringWithFormat:@"0%d",self.secondsLeft];
    self.showLbl.text=[NSString stringWithFormat:@"0%d",self.secondsLeft];

}
if (self.secondsLeft==0)
{
    [self.timer invalidate];
    self.timeLbl.text=@"";
}

  }
   -(void)showTimer
    {
   self.timeLbl.text=[NSString stringWithFormat:@"%d",self.secondsLeft];
  NSLog(@"this is self second%d",self.secondsLeft);


}

这意味着在方法中不包括以下行:-

[tableView reloadData];
试试这个

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
      {
    NSString *CellIdentifier = [NSString stringWithFormat:@"%d_%d",indexPath.section,indexPath.row];
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];

if (cell == nil) {
    cell = [[MyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
[[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil];
    cell=customCell;

}
将ReuseIdentifier设置为nil。

如果您有任何问题,请告诉我。

更新的答案

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:nil];

    if (cell == nil) {

        cell = (CustomCell *)[[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] objectAtIndex:0];
    }
cell.textLabel.text=@"XYZ";
}

不,这并不意味着在滚动计时器标签时隐藏一个问题,从何处调用此showTimer方法-(void)tableView:(UITableView*)tableView DidSelectRowatineXpath:(NSIndexPath*)indexPath{MyCell*单元格=(MyCell*)[tableView CellForRowatineXpath:indexPath];[cell startTimer:indexPath];}我使用了你的代码,但同样的事情正在发生,谢谢你。请参阅我的更新答案。试试看,让我知道。我不必在这里使用cell.textlab.text,我必须在myCell类中使用它,你可以在上面看到我的代码。
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:nil];

    if (cell == nil) {

        cell = (CustomCell *)[[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] objectAtIndex:0];
    }
cell.textLabel.text=@"XYZ";
}