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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:59:04+00:00 2026-06-13T01:59:04+00:00

I use the following code to make fixed row headers in my UIScrollView descendant.

  • 0

I use the following code to make “fixed” row headers in my UIScrollView descendant. It works well with the Simulator, but unfortunately, it flickers on the iPad. (To the left of the row header views, a white 1px line appears and disappears.) What can be improved?

- (void)initSubviews
{
    const int ROW_COUNT = 20;
    rowHeaderViews = [[NSMutableArray alloc]initWithCapacity:ROW_COUNT];
    rowViews = [[NSMutableArray alloc]initWithCapacity:ROW_COUNT];

    [self setContentSize:CGSizeMake(2000, [self frame].size.height)];

    for (int i = 0; i < ROW_COUNT; i++)
    {
        UIView *header = [self createRowHeaderViewForRowNum:i];
        [rowHeaderViews addObject:header];

        UIView *row = [self createRowViewForRowNum:i];
        [rowViews addObject:row];

        [self addSubview:row];
        [self addSubview:header];
    }
    [self layoutSubviews];
}

- (void)layoutSubviews
{
    int x = [self contentOffset].x;
    for (UIView *view in rowHeaderViews) {
        [view setFrame:CGRectMake(x, view.frame.origin.y, view.frame.size.width, view.frame.size.height)];
    }
}

- (UIView *)createRowHeaderViewForRowNum: (int)rowNum
{
    UILabel *view = [[UILabel alloc]initWithFrame:CGRectMake(0, rowNum * 20, 200, 20)];
    [view setBackgroundColor:[UIColor colorWithWhite:0.8*(20-rowNum)/20 alpha:1]];
    [view setText:[NSString stringWithFormat:@"Row Header %d", rowNum]];
    return view;
}

- (UIView *)createRowViewForRowNum: (int)rowNum
{
    UILabel *view = [[UILabel alloc]initWithFrame:CGRectMake(200, rowNum * 20, 1800, 20)];
    [view setBackgroundColor:[UIColor colorWithRed:rowNum/20.0 green:0 blue:0 alpha:1]];
    [view setText:[NSString stringWithFormat:@"Row Content %d", rowNum]];
    return view;
}

Thank you very much for any help!

EDIT: The iPad has got a Retina display. When using the Simulator with a “normal” iPad, it does not flicker. When switching the Simulator to a “Retina display” iPad, there is this flickering, too. Maybe this is something about the points/pixels difference?

  • 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-13T01:59:05+00:00Added an answer on June 13, 2026 at 1:59 am

    I found the bug on my own. Sorry for bothering you.
    In case anybody else has got the same problem:
    contentOffset.x is a float value and contains .5 values for Retina displays.
    Assigning it to an int variable in layoutSubviews caused the problem.
    This is the fix (note I replaced ‘int’ with ‘CGFloat’):

    - (void)layoutSubviews
    {
        CGFloat x = [self contentOffset].x;
        for (UIView *view in rowHeaderViews) {
            [view setFrame:CGRectMake(x, view.frame.origin.y, view.frame.size.width, view.frame.size.height)];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use the following code to make my ImageButton invisible, but clicking
I use the following code to make Propel 1.4 works in a php file.
I use the following piece of code to make a div's position fixed when
I'm trying to use the following code to make an image fadeOut and, only
I use the following code to make sure I go back to a particular
I added the following code to make use of appearance on newer versions of
I use following code: Create a retry policy, when error, retry after 1 second,
I just use following code to add an image to my project, var paper
I use VS2010, C# to develop Silverlight 4 app, I use following code in
I have an array of objects, and i use following code to get in

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.