【问题标题】:Display Label on TableView . This disappear when scrolling TableView在 TableView 上显示标签。滚动 TableView 时消失
【发布时间】:2013-11-15 10:42:56
【问题描述】:

我有一个带有隐藏标签的 TableView,只有当我通过 didSelectRow 单击单元格时才会出现。

到目前为止一切顺利,当我选择单元格时,会显示橙色标签(如您从图像中看到的那样),但是当 tableView 滚动时出现问题,橙色标签消失并且只有在我更改页面时才会返回...

橙色标签指示好友请求是否处于待处理状态,并且由于使用 prepareforsegue 报告的可变数组,因此引用了另一个页面中存在的查询。

你能解释为什么橙色标签消失了吗?当我选择单元格时,如何让它留在 TableView 上? 橙色标签是“RichiestaInAttesaLabel” 附:我正在使用 Parse.com

-(UITableViewCell * )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  {

    static NSString *CellIdentifier = @"Cell";

    FFCustomCellUtentiGenerali  *cell =[self.TableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[FFCustomCellUtentiGenerali alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];


    }


if (!isFiltered) {

    PFObject *object = [self.Utenti objectAtIndex:indexPath.row];

    NSString *str = [object objectForKey:FF_USER_NOMECOGNOME];
    cell.NomeCognome.text = str;

    cell.FFFotoProfilo.file = [object objectForKey:FF_USER_FOTOPROFILO];
    cell.FFFotoProfilo.image = [UIImage imageNamed:@"FFNoFotoUSer"];
    [cell.FFFotoProfilo.layer setMasksToBounds:YES];
    [cell.FFFotoProfilo.layer setCornerRadius:30.0f];
    cell.FFFotoProfilo.contentMode = UIViewContentModeScaleAspectFill;
    [cell.FFFotoProfilo loadInBackground];

    [cell.BackgroundReputazioneBlu.layer setMasksToBounds:YES];
    [cell.BackgroundReputazioneBlu.layer setCornerRadius:15.0f];
    [cell.BackGroundReputazione.layer setMasksToBounds:YES];
    [cell.BackGroundReputazione.layer setCornerRadius:17.0f];
    [cell.TapAggiungiLabel.layer setMasksToBounds:YES];
    [cell.TapAggiungiLabel.layer setCornerRadius:3.0f];
    [cell.RichiestaInAttesaLabel.layer setMasksToBounds:YES];
    [cell.RichiestaInAttesaLabel.layer setCornerRadius:3.0f];

    PFUser *user = [self.Utenti   objectAtIndex:indexPath.row];
    [cell.TapAggiungiLabel setHidden:YES];
    [cell.RichiestaInAttesaLabel setHidden:NO];


    if ([self isFriend:user]) {
         [cell.TapAggiungiLabel setHidden:YES];
        [cell.RichiestaInAttesaLabel setHidden:YES];
    }

    else {


        [cell.TapAggiungiLabel setHidden:NO];
        [cell.RichiestaInAttesaLabel setHidden:YES  ];
    }



    if ([self Is_InAttesa:user]) {
        [cell.RichiestaInAttesaLabel setHidden:NO];
        [cell.TapAggiungiLabel setHidden:YES];

    }

    else {
        [cell.RichiestaInAttesaLabel setHidden:YES];

    }

}
//end IsFiltred
else {

【问题讨论】:

  • 在哪里完成 if(!isFiltered) { ?

标签: ios label tableview parse-platform pfquery


【解决方案1】:
if ([self isFriend:user]) {
     [cell.TapAggiungiLabel setHidden:YES];
    [cell.RichiestaInAttesaLabel setHidden:YES];
}

else {


    [cell.TapAggiungiLabel setHidden:NO];
    [cell.RichiestaInAttesaLabel setHidden:YES  ];
}

为什么在这两种情况下都是“cell.RichiestaInAttesaLabel setHidden:YES”?

【讨论】:

  • 因为 self isFriend:用户识别他们是否是朋友 self Is_InAttesa:用户识别请求是否处于未决状态
  • 你为什么不设置“[cell.RichiestaInAttesaLabel setHidden:YES];”一次在开头并在“if ([self Is_InAttesa:user]) {...”中将其更改为“NO”?
  • 我尝试这样做,但是当我滚动 TableView 时,橙色标签消失了
  • 你能在方法的最后记录 cell.RichiestaInAttesaLabel.hidden 吗?看得见吗?
  • 请原谅翻译疯了……我听不懂你想说什么
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-23
相关资源
最近更新 更多