这个问题真的很老,但我觉得无论如何我都应该回答这个问题,因为我自己刚刚找到了解决方案。
只有单元格的 ContentView 使用确认按钮调整大小。如果您不将视图(标签、图像视图等)添加到 cell.contentView 而不是直接将它们添加到单元格,那么在调整 contentView 大小时它们将不会调整大小。就我而言,我直接将它添加到单元格中。
所以,而不是做类似的事情:
UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, width-10, 20)];
[nameLabel setFont:[UIFont boldSystemFontOfSize:16]];
[nameLabel setHighlightedTextColor:[UIColor whiteColor]];
[nameLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[nameLabel setTag:101];
[cell addSubview:nameLabel];
[nameLabel release];
你应该做:
UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, width-10, 20)];
[nameLabel setFont:[UIFont boldSystemFontOfSize:16]];
[nameLabel setHighlightedTextColor:[UIColor whiteColor]];
[nameLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[nameLabel setTag:101];
[[cell contentView] addSubview:nameLabel]; // <<--- note the change in this line!
[nameLabel release];
希望这可以帮助其他偶然发现此问题的人。