У меня есть UIViewController с выходом UITableView, который я заполняю ячейками (настроенными как выходы ivar), которые определены в том же файле пера, что и контроллер табличного представления. Поскольку я использую функцию поворота, первая ячейка увеличивается на 2 пикселя каждый раз, когда я поворачиваюсь в новую ориентацию.
Вот вывод с консоли. Я поместил вызов METHOD_LOG в каждый метод класса, чтобы я мог видеть, происходит ли код где-то неожиданно, но, похоже, это не так ...
2011-06-08 10:10:42.050 MyApp[10927:207] METHOD_LOG: viewDidLoad /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.054 MyApp[10927:207] METHOD_LOG: viewWillAppear: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.054 MyApp[10927:207] METHOD_LOG: shouldAutorotateToInterfaceOrientation: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.056 MyApp[10927:207] METHOD_LOG: numberOfSectionsInTableView: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.056 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.056 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.057 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.057 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.058 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.058 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.059 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.059 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.060 MyApp[10927:207] item name cell height: 44.000000
2011-06-08 10:10:42.060 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.060 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.061 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.061 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.062 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.062 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.062 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.063 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.063 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.064 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.064 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.065 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.065 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.065 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.066 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.066 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.067 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.067 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.068 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.068 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.068 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.069 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.069 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.070 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.070 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.071 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.071 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.071 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.072 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.072 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.073 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.073 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.074 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.074 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.074 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.075 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.075 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.076 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.076 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.077 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.077 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.077 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.078 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.078 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.079 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.079 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.080 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.080 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.080 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.081 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.081 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.082 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.082 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.082 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.083 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.083 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.084 MyApp[10927:207] METHOD_LOG: tableView:cellForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.085 MyApp[10927:207] METHOD_LOG: tableView:cellForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.086 MyApp[10927:207] METHOD_LOG: tableView:cellForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.087 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.088 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:42.088 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.619 MyApp[10927:207] METHOD_LOG: shouldAutorotateToInterfaceOrientation: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.622 MyApp[10927:207] METHOD_LOG: numberOfSectionsInTableView: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.623 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.623 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.624 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.624 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.625 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.625 MyApp[10927:207] METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.625 MyApp[10927:207] METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.626 MyApp[10927:207] METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.m
2011-06-08 10:10:49.626 MyApp[10927:207] item name cell height: 46.000000
Как вы можете видеть, после загрузки представления, единственные вызываемые методы - mustAutorotateToInterfaceOrientation и методы делегата табличного представления. В первый раз, когда вы видите высоту ячейки, это значение по умолчанию, как определено в Интерфейсном Разработчике, но во второй раз, это как-то на два пикселя больше Ни в одном из этих методов нет кода, который бы изменял границы или фрейм любого объекта.
У кого-нибудь есть идеи, что может происходить или как диагностировать проблему? Я думал о создании КВО, но я не думаю, что смогу добраться до рамки камеры с этим.
РЕДАКТИРОВАТЬ: Вот код, который возвращает высоту строки в определенном пути индекса:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
METHOD_LOG;
int idx = [indexPath section];
if (idx == SECTION_ITEM)
{
NSLog(@"item name cell height: %f", itemNameCell.frame.size.height);
return itemNameCell.frame.size.height;
}
else if (idx == SECTION_DESCRIPTION)
{
return itemDescriptionCell.frame.size.height;
}
...
... other section identifiers here, you get the idea
...
return 44.0;
}
РЕДАКТИРОВАТЬ 2: Вот код, который создает и возвращает ячейки:
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
METHOD_LOG;
UITableViewCell *cell;
int idx = [indexPath section];
if (idx == SECTION_ITEM)
{
cell = itemNameCell;
UILabel *label = (UILabel *)[cell viewWithTag:1];
label.text = [[jobItem jItemRef] blankIfNULL];
}
else if (idx == SECTION_DESCRIPTION)
{
cell = itemDescriptionCell;
UITextView *textView = (UITextView *)[cell viewWithTag:1];
textView.text = [[jobItem jItemDesc] blankIfNULL];
}
...
... again, you get the idea
...
return cell;
}