【发布时间】:2013-11-04 12:46:29
【问题描述】:
我的代码如下,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"Color Cell" forIndexPath:indexPath];
......
......
......
if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation])) {
cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:14.0f];
} else {
cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue-Thin" size:24.0f];
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat rowHeight;
if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation])) {
rowHeight = ([[UIScreen mainScreen] bounds].size.width - 52) / [colorArray count];
} else {
rowHeight = ([[UIScreen mainScreen] bounds].size.height - 64) / [colorArray count];
}
return rowHeight;
}
运行它时,表格视图可以正确地自动重新定向,单元格高度也是如此。但单元格文本大小不会相应改变。
为什么?如何解决?
左边是纵向,右边是横向
【问题讨论】:
-
字体似乎变小了。我认为横向模式下单元格高度和字体大小的比例不正确。只是进一步减小字体大小。
-
不,纵向和横向的文本大小完全相同,不会根据方向改变。只有单元格高度可以。我添加了比较快照。
-
您在 IB 中设置了最小字体大小吗?
-
试过了,甚至设置的最小尺寸(9 pt)比代码中设置的尺寸(14)更小。但什么都没有改变。
标签: ios uitableview uiinterfaceorientation landscape-portrait