Frame is not changing in cellForRowAtIndexPath

前端 未结 2 579
故里飘歌
故里飘歌 2021-01-27 19:44

I want to change the x position frame of view inside the cell in cellForRowAtIndexPath for certain conditions. I have used the following code. But it d

相关标签:
2条回答
  • 2021-01-27 20:11

    Do not change the Frame in cellForRowAtIndexPath try Changing it in willDisplayingCell Method

    0 讨论(0)
  • 2021-01-27 20:19

    Because of the iOS layout render process, your custom UITableViewCell's layoutSubviews may called more than once. In your case you can change the items frames in the GoalDetailsTableViewCell class's layoutSubviews method.

    @implementation GoalDetailsTableViewCell
    
    -(void)layoutSubviews
    {
        [super layoutSubviews];
        [UIView animateWithDuration: 0.5 animations:^{
                        cell.cardDetails.frame = CGRectOffset(cell.cardDetails.frame, -322.0, 0.0);
                        //        CGRectOffset(cell.cardView.frame, -320.0, 0.0);
                        cell.actionCardReminder.frame = CGRectOffset(cell.actionCardReminder.frame, -322.0, 0.0);
                    }];
         NSLog(@"%f", cell.cardDetails.frame.origin.x);
    }
    @end
    
    0 讨论(0)
提交回复
热议问题