我的代码如下,
- (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;
}
运行它时,表格视图可以正确地自动重新定向,单元格高度也是如此。但单元格文本大小不会相应改变。
为什么?如何解决?
左边是纵向,右边是横向