0

I have a problem with indention in UITableView. See image to make it clear.

enter image description here

There are just cell with UILabel. After launching app, all points have the same indention (like points Schedule & Favourites on picture). But when I scroll it up & then scroll it down back, the indention of labels changes. It appeared in iOS6 as well as in iOS7.

Does anybody have ideas how to fix it?

EDIT0: It seems than only first rendering (before screen is appeared) works well. All others calls "cellForRowAtIndexPath" return incorrect cell view. Might be it connected w/ constraints... but i'm not sure.
Anyway the way are supposed by NSS works. Thanks everybody for your help.

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
//#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    //#warning Incomplete method implementation.
    // Return the number of rows in the section.

    return [activeList count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"mainPointCell";
    OMSMainActiveCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    // Configure the cell...
    [cell.textLabel setText:[activeList objectAtIndex:indexPath.row]];

    return cell;
}
user3124812
  • 1,861
  • 3
  • 18
  • 39

2 Answers2

1

Add following code in your custom cell class i. e. in OMSMainActiveCell

- (void) layoutSubviews 
  {
      [super layoutSubviews];
      self.textLabel.frame = CGRectMake(0, 0, 320, 20);
  }

Also you can see this answer.

Hope this helps you.

Community
  • 1
  • 1
Nayan
  • 3,014
  • 2
  • 17
  • 33
0

Try to set frame of your label like

[label setFrame:CGRectMake(cell.frame.origin.x , cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)];

if still its happening then let us know

Retro
  • 3,985
  • 2
  • 17
  • 41
  • I think he is not using custom label! he is using cell's by default textLabel property. – Nayan Jan 14 '14 at 05:48
  • Do one thing, set the label background color and see its movie or what else happening – Retro Jan 14 '14 at 06:22
  • @Retro Yes, it moves left... [Look there](https://drive.google.com/file/d/0B-Zu9D9ZQvSVRTlZdUhoamQ4RFE/edit?usp=sharing) Green label in top-left shows original 20pxl indent. – user3124812 Jan 14 '14 at 06:45