iOS 6 自定义分组 UITableViewCell 大小不正确

标签 ios objective-c ipad uitableview

我创建了一个 UITableViewCell包含 UITextField 的子类.但是,当我将该单元格添加到 iOS 6 中的分组表格 View 时,单元格会扩展到表格 View 边缘。

The Name field is extended but the Company and Season fields are in the same tableview yet the correct size

这是自定义单元格的代码。

#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执行。德普...

enter image description here

关于iOS 6 自定义分组 UITableViewCell 大小不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22296588/

相关文章:

iphone - 如何在 iPhone 或 iPad 中从 ppt 文件中的幻灯片中获取图像?

ios - 如何移动文本框?

ios - 如何在 xcode 中打开现有的本地 pod?

ios - 使用哪个 Google Analytics cocoapods pod

javascript - 当页面作为 Web 独立应用程序时,错误的 webkit-tap-highlight-color 行为

iphone - 如何设置popOverController的宽高

iphone - 这是允许的吗?通过 XML-RPC 在 iOS 上更新内容

iphone - 我如何了解 IOS 应用程序是否进入后台?

ios - AVCaptureSession 在 iPad 上工作正常但在 iPhone 上不行

objective-c - 将 YUV 数据写入 CGContext