在自定义 UITableViewCell 的 layoutSubviews 方法中添加如下代码
- (void)layoutSubviews { [super layoutSubviews]; if (self.superview) { if (CGAffineTransformEqualToTransform(self.superview.transform, CGAffineTransformIdentity)) { CGRect frame = self.frame; frame.size.width = self.superview.frame.size.width; self.frame = frame; }else{ CGRect frame = self.frame; frame.size.width = self.superview.frame.size.height; self.frame = frame; } } }