0

I am Using StoryBoard and Using Autolayout , I have set Constraints at runtime for Custom cell.Also I have set constraints in ViewDidLayoutSubviews to Handle Device Orientation. So This is taking time for Cell to configure and my cell is not Scrolling Smoothly .Can anyone help me on this?If I have to not set constraints at runtime then where should I set them?Hope I am Clear.Thanks in advance

Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
Asmi237
  • 33
  • 8
  • with this limited information it is impossible to determine the potential issues in your app... you'll have to provide more context otherwise it'll be difficult to help – nburk Jun 05 '15 at 07:01
  • post your code about setting the constraints and CellForRowAtIndexPath – Wingzero Jun 05 '15 at 08:39

2 Answers2

0

I'm with nburk, it is not possible to solve with this short detail. But as You are using custom cell in tableView. In the cellForRowAtIndexPath method every time the cell is created so you can use dispatch_async(dispatch_get_main_queue(), ^{......your code here for custom cell..... }); //used for updating UI I'm not sure but as your lines it showing the screen UI is not updating on time.

Ankit Kumar
  • 280
  • 2
  • 17
0

I would suggest you to define a UITableViewCell's subclass and create all constraints in the init/initWithCoder: method.

And don't forget to reuse your cells correctly. In this way you won't re-create your cell's constraints all the time.

EDIT: take a look at the example below.

static NSString* const kCellIdentifier = @"CustomTableViewCellIdentifier";

@implementation CustomTableViewController

- (void)viewDidLoad
{
    [self.tableView registerClass:[CustomTableViewCell class] forCellReuseIdentifier:kCellIdentifier];
}

- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
    CustomTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
    // configure your cell here
    return cell;
}

@end


@interface CustomTableViewCell: UITableViewCell
@end

@implementation CustomTableViewCell

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // add subviews and install constraints here. Don't forget to use contentView instead of cell when you install constraints.
    }

    return self;
}

@end
sgl0v
  • 1,357
  • 11
  • 13