Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么tableview单元格文本不随方向而改变,而单元格高度却随方向而改变_Ios_Uitableview_Uiinterfaceorientation_Landscape Portrait - Fatal编程技术网

Ios 为什么tableview单元格文本不随方向而改变,而单元格高度却随方向而改变

Ios 为什么tableview单元格文本不随方向而改变,而单元格高度却随方向而改变,ios,uitableview,uiinterfaceorientation,landscape-portrait,Ios,Uitableview,Uiinterfaceorientation,Landscape Portrait,我的代码如下: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"Color Cell" forIndexPath:indexPath]; ......

我的代码如下:

- (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;
}
当运行它时,表格视图可以自动正确地重新定向,单元格高度也可以。但单元格文本大小不会相应地改变

为什么??如何修复它

左边是肖像画,右边是风景画


UITableViewCell
在设备中更改方向时不重新加载,在更改方向后重新加载表格视图

字体大小似乎减小了。我认为在横向模式下,单元格高度和字体大小的比例是不正确的。只需进一步减小字体大小。不,纵向和横向中的文本大小完全相同,不随方向而改变。只有细胞高度有影响。我添加了一个比较快照。您在IB中设置了最小字体大小吗?尝试过了,甚至设置了比代码中设置的最小字体大小(9磅)更小的字体大小(14磅)。但是没有改变。你是说
self.tableView重新加载数据
?放在哪里?添加self.tableView在更改方向时重新加载数据。将其添加到
viewDidLoad
(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
,或其他?-(void)将旋转到InterfaceOrientation:(UIInterfaceOrientation)到InterfaceOrientation持续时间:(NSTimeInterval)持续时间{if(端口右侧){//reload action;}否则{//reload action;}}