Я добавляю ячейку uitableview в качестве подпредставления в UIView, которая также является подвидом представления ViewController. но по какой-то причине UITableViewCell по-прежнему растягивает 320 пикселей по экрану, когда я инициализирую его чем-то гораздо меньшим.
Даже если я сделаю вид маленьким, он все равно останется 320 пикселей в ширину. Мне интересно, проблема ли это иерархии? Я чувствую, что мой код правильный, но, может быть, я просто упускаю что-то маленькое ...
//..
// This UIView holds both custom UITableViewCell and UIButton and is placed at the top of the current UIView
cellContainer = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 44.0)];
cellContainer.backgroundColor = [UIColor greenColor];
// Select all UITableViewCell
selectAllCell = [[UITableViewCell alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 7.0)];
selectAllCell.textLabel.text = @"Select all"; // Set text
// selectAllCell.accessoryType = UITableViewCellAccessoryCheckmark;
selectAllCell.backgroundColor = [UIColor redColor]; // set bg color
// Create non visible UIButton that sits over customTableviwecell wich allows you to set a selctor on the button press
UIButton *selectAllButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 50.0)];
[selectAllButton addTarget:self action:@selector(selectAll:) forControlEvents:UIControlEventTouchUpInside];
// Add custom Cell and UIButton to cellContainer view
[cellContainer addSubview:selectAllCell];
[cellContainer insertSubview:selectAllButton aboveSubview:selectAllCell];
// Ass cellContainer to self.view
[self.view insertSubview:cellContainer atIndex:1];
//..