gpt4 book ai didi

IOS - 静态 UITableViewCell - 返回当前高度

转载 作者:行者123 更新时间:2023-11-29 03:19:26 25 4
gpt4 key购买 nike

我正在尝试使用静态 UiTableViewController 构建表单 - 我想实现 IOS7 显示方法以内联显示 UIPickerView/UidateView,但由于表格是静态的而不是动态的,它被证明是有问题的。

无论如何 - 我在这个问题中遵循了 Aaron Bratcher 的解决方案 - iOS 7 - How to display a date picker in place in a table view? -

看起来它非常适合 - 我唯一的问题是我的表格单元格具有不同的高度 - 所以我需要为日期选择器行返回 200 或零的高度 - 但对于其他所有内容,他们需要保持当前高度 - 我不确定最好的编码方式是什么 - 我需要引用当前单元格并且基本上说保持原样,除非你的 pickerRow?

这是我到目前为止得到的 -

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 5 && indexPath.row == 1) { // this is my picker cell
if (_editingStartTime) {
return 220;
} else {
return 0;
}
} else {

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

//return THE CURRENT CELLS HEIGHT
}
}

不确定我如何访问上方单元格的高度 - 甚至不确定该逻辑是否会执行我希望它在 heightForRowAtIndexPath 中执行的操作?有什么想法吗?

干杯

最佳答案

在静态 tableView 中,您可以向 super 询问 Storyboard中存在的单元格的高度。

例如:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
/* ... */
else {
CGFloat height = [super tableView:tableView heightForRowAtIndexPath:indexPath];
return height;
}
}

其他数据源方法也是如此,因此您也可以从 - tableView:numberOfRowsInSection: 中删除一些代码。

关于IOS - 静态 UITableViewCell - 返回当前高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21282517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com