我创建了一个 UITableViewCell
包含 UITextField
的子类.但是,当我将该单元格添加到 iOS 6 中的分组表格 View 时,单元格会扩展到表格 View 边缘。
这是自定义单元格的代码。
#import "ActivityNameEditCell.h"
@implementation ActivityNameEditCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.textField = [[UITextField alloc] init];
[self addSubview:self.textField];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)layoutSubviews
{
self.textField.frame = CGRectMake(self.contentView.frame.origin.x + 10, 0, self.frame.size.width - self.contentView.frame.origin.x - 10, self.frame.size.height);
}
@end
这个相同的单元类在 iOS 7 中正确布局
有什么明显的地方表明我做错了吗?如何修复 iOS 6 中的单元格?
最佳答案
我只是忘了打[super layoutSubviews]
在我的layoutSubviews
执行。德普...
关于iOS 6 自定义分组 UITableViewCell 大小不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22296588/