<i id='y6qgD'><tr id='y6qgD'><dt id='y6qgD'><q id='y6qgD'><span id='y6qgD'><b id='y6qgD'><form id='y6qgD'><ins id='y6qgD'></ins><ul id='y6qgD'></ul><sub id='y6qgD'></sub></form><legend id='y6qgD'></legend><bdo id='y6qgD'><pre id='y6qgD'><center id='y6qgD'></center></pre></bdo></b><th id='y6qgD'></th></span></q></dt></tr></i><div id='y6qgD'><tfoot id='y6qgD'></tfoot><dl id='y6qgD'><fieldset id='y6qgD'></fieldset></dl></div>

<small id='y6qgD'></small><noframes id='y6qgD'>

    1. <legend id='y6qgD'><style id='y6qgD'><dir id='y6qgD'><q id='y6qgD'></q></dir></style></legend><tfoot id='y6qgD'></tfoot>
      • <bdo id='y6qgD'></bdo><ul id='y6qgD'></ul>

      旋转自定义 UITableViewCell

      Rotate a custom UITableViewCell(旋转自定义 UITableViewCell)

        <legend id='cmEpz'><style id='cmEpz'><dir id='cmEpz'><q id='cmEpz'></q></dir></style></legend>

            <tbody id='cmEpz'></tbody>

            • <bdo id='cmEpz'></bdo><ul id='cmEpz'></ul>

              <small id='cmEpz'></small><noframes id='cmEpz'>

              <tfoot id='cmEpz'></tfoot>
                <i id='cmEpz'><tr id='cmEpz'><dt id='cmEpz'><q id='cmEpz'><span id='cmEpz'><b id='cmEpz'><form id='cmEpz'><ins id='cmEpz'></ins><ul id='cmEpz'></ul><sub id='cmEpz'></sub></form><legend id='cmEpz'></legend><bdo id='cmEpz'><pre id='cmEpz'><center id='cmEpz'></center></pre></bdo></b><th id='cmEpz'></th></span></q></dt></tr></i><div id='cmEpz'><tfoot id='cmEpz'></tfoot><dl id='cmEpz'><fieldset id='cmEpz'></fieldset></dl></div>
                本文介绍了旋转自定义 UITableViewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有一个自定义 UITableViewCell,其中包含几个 UIButton.每个按钮的框架位置都与单元格宽度相关.我设置了 autoresizingMask=UIViewAutoresizingFlexibleWidth ,因此当应用程序以横向或纵向模式启动设备时,它将正确调整单元格宽度和按钮位置.

                I have a custom UITableViewCell which contains several UIButtons. Each button's frame position is relative to the cell width. I set autoresizingMask=UIViewAutoresizingFlexibleWidth so it will adjust the cell width and the button positions properly when the application starts with the device either in landscape or portrait mode.

                问题是当设备从一种模式旋转到另一种模式时,按钮不会调整位置,因为 UITableViewCell 是可重复使用的.换句话说,单元格没有根据新的 UITalbeView 宽度进行初始化,因为单元格的函数 initWithStyle 在设备旋转之前被调用,并且在设备旋转之后不再被调用.有什么建议吗?

                The issue is when the device is rotated from one mode to the other, the buttons do not adjust positions because the UITableViewCell is reusable. In other words, the cell is not initialized based on the new UITalbeView width because the cell's function initWithStyle is called before the device is rotated and is not called again after the device rotation. Any suggestions?

                推荐答案

                经过数小时的研究(包括本站的帖子),我找不到任何解决方案.但是一个灯泡突然亮了起来.解决方案非常简单.只需检测设备方向是横向还是纵向模式,并为每个定义 ReusableCellIdentifier 并使用不同的名称.

                After spending hours of research (including posts in this site), I could not find any solutions. But a light bulb turns on all of a sudden. The solution is very simple. Just detect whether the device orientation is landscape or portrait mode and define the ReusableCellIdentifier with a different name for each.

                static NSString*Identifier;
                
                if ([UIDevice currentDevice].orientation!=UIDeviceOrientationLandscapeLeft && [UIDevice currentDevice].orientation!=UIDeviceOrientationLandscapeRight) {
                                Identifier= @"aCell_portrait";
                            }
                            else Identifier= @"DocumentOptionIdentifier_Landscape";
                
                
                    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Identifier];
                

                这篇关于旋转自定义 UITableViewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How To Create a Rotating Wheel Control?(如何创建转轮控件?)
                iOS 6 rotations: supportedInterfaceOrientations doesn#180;t work?(iOS 6 旋转:supportedInterfaceOrientations 不起作用?)
                CABasicAnimation rotate returns to original position(CABasicAnimation 旋转返回原始位置)
                How to avoid restarting activity when orientation changes on Android(如何在 Android 上的方向更改时避免重新启动活动)
                UITabBarController Rotation Issues in ios 6(ios 6 中的 UITabBarController 旋转问题)
                iOS: How to run a function after Device has Rotated (Swift)(iOS:设备旋转后如何运行函数(Swift))
              1. <legend id='X4IkB'><style id='X4IkB'><dir id='X4IkB'><q id='X4IkB'></q></dir></style></legend>

                  <small id='X4IkB'></small><noframes id='X4IkB'>

                  <tfoot id='X4IkB'></tfoot>

                        <i id='X4IkB'><tr id='X4IkB'><dt id='X4IkB'><q id='X4IkB'><span id='X4IkB'><b id='X4IkB'><form id='X4IkB'><ins id='X4IkB'></ins><ul id='X4IkB'></ul><sub id='X4IkB'></sub></form><legend id='X4IkB'></legend><bdo id='X4IkB'><pre id='X4IkB'><center id='X4IkB'></center></pre></bdo></b><th id='X4IkB'></th></span></q></dt></tr></i><div id='X4IkB'><tfoot id='X4IkB'></tfoot><dl id='X4IkB'><fieldset id='X4IkB'></fieldset></dl></div>

                        • <bdo id='X4IkB'></bdo><ul id='X4IkB'></ul>
                            <tbody id='X4IkB'></tbody>