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 8732873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:31:28+00:00 2026-06-13T09:31:28+00:00

Why setIndentationLevel is not getting with cells subviews? I have a UITableView . My

  • 0

Why setIndentationLevel is not getting with cells subviews?
I have a UITableView. My cellForRowAtIndexPath is like below. The arrow which i added is not shifting with the textlabel. why?

How can I do this?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    UIImageView *img = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"small_arrow.png"]];
    img.frame = CGRectMake(5, 10, 7, 11);
    [cell.contentView addSubview:img];

    cell.textLabel.text=[[self.tabledata objectAtIndex:indexPath.row] valueForKey:@"name"];
    cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:18];

    [cell setIndentationLevel:[[[self.tabledata objectAtIndex:indexPath.row] valueForKey:@"level"] intValue]];


    return cell;
}
  • 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-13T09:31:30+00:00Added an answer on June 13, 2026 at 9:31 am

    Yeah !!! Its workin now.
    I created a custom cell and its m file is like

    #import "customecell.h"
    
    @implementation customecell
    
    @synthesize textLbl,img;
    
    - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            // Initialization code
    
            textLbl = [[UILabel alloc]initWithFrame:CGRectMake(15, 10, 320, 20)];
            textLbl.backgroundColor = [UIColor clearColor];
            [self.contentView addSubview:textLbl];
    
    
            img = [[UIImageView alloc]initWithFrame:CGRectMake(5, 10, 7, 11)];
            img.image = [UIImage imageNamed:@"small_arrow.png"];
            [self.contentView addSubview:img];
    
        }
        return self;
    }
    
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
        [super setSelected:selected animated:animated];
    
        // Configure the view for the selected state
    }
    
    - (void)layoutSubviews{
        [super layoutSubviews];
        float indentPoints = self.indentationLevel * self.indentationWidth;
    
        self.contentView.frame = CGRectMake(
                                        indentPoints,
                                        self.contentView.frame.origin.y,
                                        self.contentView.frame.size.width - indentPoints,
                                        self.contentView.frame.size.height
                                        );
    }
    
    @end
    

    and the cellForRowAtIndexPath is changed to

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        static NSString *CellIdentifier = @"Cell";
    
        customecell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[customecell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        }
    
        cell.textLbl.text=[[self.tabledata objectAtIndex:indexPath.row] valueForKey:@"name"];
        cell.textLbl.font = [UIFont fontWithName:@"Helvetica" size:18];
    
        [cell setIndentationLevel:[[[self.tabledata objectAtIndex:indexPath.row] valueForKey:@"level"] intValue]];
        cell.indentationWidth = 25;
    
        float indentPoints = cell.indentationLevel * cell.indentationWidth;
    
        cell.contentView.frame = CGRectMake(indentPoints,cell.contentView.frame.origin.y,cell.contentView.frame.size.width - indentPoints,cell.contentView.frame.size.height);
    
        return cell;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created the below code to display buttons in UITableView . I want
I have a UITableView in my project with rows being initialised as default UITableViewCell
If I call setIndentationLevel: on an NSMenuItem then nothing happens, if I call indentationLevel
I want to add an image on top of another image button in a

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.