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

  • SEARCH
  • Home
  • 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 7761455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:08:25+00:00 2026-06-01T14:08:25+00:00

I want to draw a vertical line between the SectionIndex column and the cell

  • 0

I want to draw a vertical line between the SectionIndex column and the cell content view. How can I do this?

Split table view with table data and sorted keys

  • 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-01T14:08:26+00:00Added an answer on June 1, 2026 at 2:08 pm

    Refer to this post:

    how to add vertical lines to a table view in iphone sdk?

    Refer to Kris Markel’s there in the above post. It suggests this link:

    http://www.iphonedevx.com/?p=153

    Note: I have copied code from the whole link and pasted it here, just to make sure answer remains useful even in case if the link goes down in future:

    UITableView is probably the most used view on the iPhone. It’s
    flexible and the UI is ideally suited to use on the iPhone. There are
    lots of examples on how to add multiple items to a UITableViewCell.
    However, I needed to present some data in a more traditional
    spreadsheet style grid. The results worked well and enabled me to pack
    a lot of information on the screen that was very hard to follow
    without the vertical grid. I’ll show a very simplified version here
    you can use to add vertical lines to your UITableView.

    First we need to create a subclass of UITableViewCell. This is so we
    can override drawrect and draw our lines
    and to add an array to hold a
    list of positions where we’ll draw the lines.

    @interface MyTableCell : UITableViewCell {
        NSMutableArray *columns;
    }
    - (void)addColumn:(CGFloat)position;
    @end
    

    In this simplified example we’ll leave the positioning of the actual
    text in the cells in the UITableViewController and place it manually
    (full source code is attached at the end). We’re just providing a
    mechanism for drawing vertical lines to make a grid. Column locations
    are added by calling addColumn:

    - (void)addColumn:(CGFloat)position {
        [columns addObject:[NSNumber numberWithFloat:position]];
    }
    

    Now lets override drawRect. In it we grab the current graphics context
    and set the line color and width. Then we iterate over our columns
    array drawing a line from the top of the cell row to the bottom at
    each position stored in the array.

    - (void)drawRect:(CGRect)rect {
        CGContextRef ctx = UIGraphicsGetCurrentContext();
        // Use the same color and width as the default cell separator for now
        CGContextSetRGBStrokeColor(ctx, 0.5, 0.5, 0.5, 1.0);
        CGContextSetLineWidth(ctx, 0.25);
    
        for (int i = 0; i < [columns count]; i++) {
            CGFloat f = [((NSNumber*) [columns objectAtIndex:i]) floatValue];
            CGContextMoveToPoint(ctx, f, 0);
            CGContextAddLineToPoint(ctx, f, self.bounds.size.height);
        }
    
        CGContextStrokePath(ctx);
    
        [super drawRect:rect];
    }
    To add columns to the view just call
    
    [cell addColumn:50];
    when you’re building each cell.
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row];
    
        MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    
        if (cell == nil) {
            cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    
            UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0, 30.0,
                                                               tableView.rowHeight)] autorelease];
            [cell addColumn:50];
            label.tag = LABEL_TAG;
            label.font = [UIFont systemFontOfSize:12.0];
            label.text = [NSString stringWithFormat:@"%d", indexPath.row];
            label.textAlignment = UITextAlignmentRight;
            label.textColor = [UIColor blueColor];
            label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin |
            UIViewAutoresizingFlexibleHeight;
            [cell.contentView addSubview:label]; 
    
            label =  [[[UILabel alloc] initWithFrame:CGRectMake(60.0, 0, 30.0,
                                                                tableView.rowHeight)] autorelease];
            [cell addColumn:120];
            label.tag = VALUE_TAG;
            label.font = [UIFont systemFontOfSize:12.0];
            // add some silly value
            label.text = [NSString stringWithFormat:@"%d", indexPath.row * 4];
            label.textAlignment = UITextAlignmentRight;
            label.textColor = [UIColor blueColor];
            label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin |
            UIViewAutoresizingFlexibleHeight;
            [cell.contentView addSubview:label];
        }
    
        return cell;
    }
    

    Hope this helps.

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

Sidebar

Related Questions

I want to draw this in my view to draw this line, I have
I have two UIScrollView instances and I want to draw a vertical line between
I want draw a line between to specify point in java 3d. how can
I want to draw a line in Crystal report. I can do that from
I want to draw a straight vertical line in my Android activity when a
I want to draw line on UIImageView. I already draw line on UIImageView but
I want to draw a number centered inside a wx.EmptyBitmap. How can I do
I want to draw a graph in my application.can any one tell me which
I need to draw an overlay over a datagrid cell. I want the overlay
I want to draw DirectX content so that it appears to be floating over

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.