bug in UITableView layout after orientation change

后端 未结 2 1930

I have an auto-layout (constraint) based application and noticed that there is a problem with a tableview after an orientation change. The repro steps are as follows (I have

2条回答
  •  庸人自扰
    2020-12-13 11:11

    I have found that the answers above work most of the time but not all of the time. The most robust solution is to subclass UITableView and set the contentSize within layoutSubviews:

    - (void)layoutSubviews
    {
        [super layoutSubviews];
    
        CGSize contentSize = self.contentSize;
        contentSize.width  = self.bounds.size.width;
        self.contentSize   = contentSize;
    }
    

提交回复
热议问题