xcode 无法在界面生成器中更改 UITableViewCell 大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2293794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:08:11  来源:igfitidea点击:

Can't change UITableViewCell size in Interface Builder

iphonexcodeuitableviewinterface-builder

提问by Ondrej Rafaj

Does anyone have the same problem as I do? ... I've upgraded to the iPhone SDK 3.2 and I am unable to resize UITableViewCell object in my XIB file (usually I've been just resizing the view but now the cell has the same size and there is just a grey are around) ... btw, I've tried to reinstall twice including one deep reinstall.

有没有人和我一样的问题?...我已升级到 iPhone SDK 3.2,但无法在我的 XIB 文件中调整 UITableViewCell 对象的大小(通常我只是调整了视图的大小,但现在单元格具有相同的大小,并且周围只有一个灰色) ...顺便说一句,我已经尝试重新安装两次,包括一次深度重新安装。

采纳答案by Justin

Hey I had this same issue. This is old, so maybe you found a solution already, but for those who haven't...

嘿,我有同样的问题。这是旧的,所以也许您已经找到了解决方案,但是对于那些还没有...

Select the cell in IB, and bring up the size panel (by clicking to it or with command-3). Under size & position, set to frame, and edit the height box there.

在 IB 中选择单元格,然后调出大小面板(通过单击它或使用 command-3)。在大小和位置下,设置为框架,并在那里编辑高度框。

Easy, huh. Don't know how we missed this.

很简单吧。不知道我们是怎么错过的。

回答by user698333

The tableviewcell size can be set by dragging the cell frame in the interface builder. Then implement then tableview delegate tableView heightForRowAtIndexPath for the particular cell you want to have a different height.

可以通过在界面构建器中拖动单元格框架来设置 tableviewcell 大小。然后为您想要具有不同高度的特定单元格实现然后 tableview 委托 tableView heightForRowAtIndexPath。

回答by RedBlueThing

I have 3.2 installed and don't have that issue. Check that you are returning the correct cell height for heightForRowAtIndexPath. So for a cell at section zero, row zero (that uses a custom UITableViewCell), use the height of the cell defined in the XIB:

我安装了 3.2,没有这个问题。检查您是否为heightForRowAtIndexPath返回了正确的单元格高度。因此,对于第 0 部分、第 0 行(使用自定义 UITableViewCell)的单元格,请使用 XIB 中定义的单元格的高度:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.section == 0 && indexPath.row == 0)
        return m_customCell.frame.size.height;
    else
        return 44;
}

回答by Codrut

first tab (Attributes) -> subtab(Simulated User Interface Elements) -> Status Bar: set(Unspecified) . Worked for me

第一个选项卡(属性)-> 子选项卡(模拟用户界面元素)-> 状态栏: set(Unspecified) 。对我来说有效

回答by EricWasTaken

The accepted answer (selecting the TableCell) and using the inspector did not work for me with XCODE 5.

接受的答案(选择 TableCell)和使用检查器在 XCODE 5 中对我不起作用。

This worked: - In interface builder, select the TABLE VIEW (NOT the TableViewCell). - Then in inspector (Size Inspector), notice at the top "Row Height". Set that as desired. - Also notice Section Height can be set here too!

这有效: - 在界面生成器中,选择 TABLE VIEW(不是 TableViewCell)。- 然后在检查器(Size Inspector)中,注意顶部的“行高”。根据需要进行设置。- 还要注意这里也可以设置截面高度!

Final note, the table cell can definitely be drag/resized as well.

最后要注意的是,表格单元格也绝对可以拖动/调整大小。