Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9239629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:01:56+00:00 2026-06-18T08:01:56+00:00

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @cell; UITableViewCell *cell

  • 0
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

//    NSLog(@"msgcnt123 %@\n",[messageCount objectAtIndex:indexPath.row]);

    NSArray *seperateArray = [[clist objectForKey:[[clist allKeys]objectAtIndex:indexPath.row]]componentsSeparatedByString:@"@"];

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//    NSLog(@"key %@\n",[[clist allKeys]objectAtIndex:indexPath.row]);

    cell.textLabel.text = [seperateArray objectAtIndex:0];
//    cell.textLabel.text = [contactlist objectAtIndex:indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

//    NSLog(@"sep %@\n",seperateArray);


    if (![[seperateArray objectAtIndex:1] isEqualToString:@"0"]) {
        NSLog(@"msgCount %@\n",[seperateArray objectAtIndex:1]);
        lblCnt = [[UILabel alloc]initWithFrame:CGRectMake(260, 13, 20, 20)];
        lblCnt.backgroundColor = [UIColor lightGrayColor];
        lblCnt.textColor = [UIColor blackColor];
        lblCnt.text = [seperateArray objectAtIndex:1];
        lblCnt.textAlignment = UITextAlignmentCenter;
        lblCnt.layer.masksToBounds = YES;
        lblCnt.layer.cornerRadius = 2.0f;
        [cell.contentView addSubview:lblCnt];

    }
    else
    {
        NSLog(@"msgCount1 %@\n",[seperateArray objectAtIndex:1]);
        [lblCnt removeFromSuperview];
        lblCnt.hidden = YES;
    }

    return cell;
}

I have added a label in each row which displays number of messages received.In didSelect method i make label count zero so i can disappear label from tableView.In case of more than one row in table view label not disappear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:01:58+00:00Added an answer on June 18, 2026 at 8:01 am

    The simple and dirty method to reach what u want is to use a tag

    -(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    static NSString *cellIdentifier = @"cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    
    NSArray *seperateArray = [[clist objectForKey:[[clist allKeys]objectAtIndex:indexPath.row]]componentsSeparatedByString:@"@"];
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = [seperateArray objectAtIndex:0];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (![[seperateArray objectAtIndex:1] isEqualToString:@"0"]) {
    
        lblCnt = [[UILabel alloc]initWithFrame:CGRectMake(260, 13, 20, 20)];
        lblCnt.backgroundColor = [UIColor lightGrayColor];
        lblCnt.textColor = [UIColor blackColor];
        lblCnt.text = [seperateArray objectAtIndex:1];
        lblCnt.textAlignment = UITextAlignmentCenter;
        lblCnt.layer.masksToBounds = YES;
        lblCnt.layer.cornerRadius = 2.0f;
        [cell.contentView addSubview:lblCnt];
    
        //Add a tag
        lblCnt.tag = 1000;
    
    
    }
    else
    {
        /*
        NSLog(@"msgCount1 %@\n",[seperateArray objectAtIndex:1]);
        [lblCnt removeFromSuperview];
        lblCnt.hidden = YES;
         */
    
    
        for (UIView *view in [cell.contentView subviews]) {
    
            if (view.tag == 1000) {
                [view removeFromSuperview];
            }
    
        }
    
    }
    
    return cell;
    }
    

    and select the view based on the tag.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edited code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @Cell;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @Cell; LocationsScreenTableViewCell *cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @Cell; UITableViewCell *cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @Cell; UITableViewCell *cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //static NSString *CellIdentifier = @Cell; NSString *CellIdentifier
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @Cell2; UILabel *titleLabel;
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *TodoListTableIdentifier = @TodoListTableIdentifier; TodoTableViewCellController
I use cellForRowAtIndexPath like here: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString
I have the following code: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString
Why this code works fine: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.