- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 iPhone 应用程序,它有一个基于 TableView 的数据输入屏幕,带有一个切换开关,打开时会显示表格另一部分中的所有行。
有时,当应用程序首次加载时,通常是当它从手机中完全删除时,除了新行之外,还会显示表格原始部分中的 UITextFields,如下所示(主表格部分在上面) )
:
最奇怪的是,这种行为仅在第一次显示此屏幕时发生 - 此后似乎很好。哦,而且它似乎只发生在手机上,而不是模拟器上。
考虑到其随机性,它是否与其他应用程序有关?我确实有同时运行的具有类似命名空间的应用程序。在我关闭应用程序/从手机中删除应用程序后,问题似乎消失了。
我已经包含了下面更改开关时运行的代码块:
- (void)accountSwitchChanged {
[customerDetails saveField:@"addToAccount" WithBool:addToAccountSwitch.on];
NSArray *indexes = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:1 inSection:1], [NSIndexPath indexPathForRow:2 inSection:1], [NSIndexPath indexPathForRow:3 inSection:1],nil];
if (addToAccountSwitch.on)
[detailsTable insertRowsAtIndexPaths:indexes withRowAnimation:UITableViewRowAnimationFade];
else
[detailsTable deleteRowsAtIndexPaths:indexes withRowAnimation:UITableViewRowAnimationFade];
}
有什么想法吗?
--编辑
cellForRowAtIndexPath 代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// get rid of grey background for iPad app
[tableView setBackgroundView:nil];
UITableViewCell *cell = nil;
NSDictionary *cellData = [[dataSourceArray objectAtIndex: indexPath.section] objectAtIndex:indexPath.row];
id cellControl = [cellData objectForKey:kCellControlKey];
static NSString *kCellControl = @"CellControl";
cell = [tableView dequeueReusableCellWithIdentifier:kCellControl];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellControl] autorelease];
cell.textLabel.textColor = [[[ConfigManager sharedInstance].skin valueForKey:@"tableCellHeadingTextColour"] toUIColor];
cell.backgroundColor = [[[ConfigManager sharedInstance].skin valueForKey:@"tableCellBgColour"] toUIColor];
cell.textLabel.font = [UIFont boldSystemFontOfSize:17];
} else {
// a cell is being recycled, remove the old control (if it contains one of our tagged edit fields)
UIView *viewToCheck = nil;
viewToCheck = [cell.contentView viewWithTag:kDetailsViewTag];
if (!viewToCheck)
[viewToCheck removeFromSuperview];
}
// if control is not a text field, make it a button
if (![cellControl isKindOfClass:[UITextField class]])
cell.selectionStyle = UITableViewCellSelectionStyleGray;
else
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = [cellData objectForKey:kCellTitleKey];
[cell.contentView addSubview:cellControl];
return cell;
}
最佳答案
需要检查和消除的内容 如果它仅在第一次显示 View 时发生,则始终值得检查您在处理 View 之前是否假设 View 已加载。这种情况并不经常出现,但一旦出现就很难追踪。要检查这是否是您的问题,请在首次创建 View 后添加 [viewController view] 调用。这会强制加载 View 。如果添加此问题后问题消失,则说明您已跟踪问题的根源。您甚至可以保留 [viewController view] 调用作为修复,或者处理您的代码以允许延迟实例化。
所有这些,在你的 tableView:cellForRowAtIndexPath: 代码中更有可能是一些有趣的事情。如果您想要良好的堆栈溢出,请发布该代码的所有或相关片段(或其调用的相关代码)。
跟进发布的代码:
(1) if (!viewToCheck) [viewToCheck removeFromSuperview]
不会执行任何操作。当 viewToCheck 为零时,它只会发送一条removeFromSuperview 消息,并且不会执行任何操作。不确定这是否是关键问题,但这是需要纠正的问题。
(2) [cell.contentView addSubview:cellControl];
- 这看起来有问题 - 通常最好在创建单元格时仅添加 subview 。您可以在 tableView:cellForRowAtIndexPath: 的主体中隐藏或显示 - 我怀疑这对您有用。使用此代码存在一个风险,即当您只需要一个 subview 时,您将添加多个 subview ,或者(这可能是这里发生的情况)您最终不会在回收单元格时删除 subview 。如果 viewToCheck
代码应该删除添加的 cellControl,那么,如 (1) 所示,它现在不会执行此操作,因为您的 if 条件错误。
关于iphone - UITextField 工件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9813637/
最近,我一直在尝试清理我的openGl渲染。我已经有一段时间了,但是从来没有真正考虑过。这是一个屏幕截图: 经过一些研究,我一直无法弄清楚它到底出了什么问题。我在OSX上使用OpenGl,但在其他系统
我尝试使用 glDrawArray 和 GL_TRIANGLE_STRIP 渲染纹理网格,但绘制时存在伪影,但在屏幕上分布不均匀。 Screenshot of the problem. 这是我使用的代
尝试使用 Github 的 beta 操作,我有两项工作,一项负责构建代码,另一项负责部署代码。但是,我似乎无法在部署作业中获取构建工件。 我最新的尝试是为每个作业手动设置具有相同卷的容器镜像,根据文
我是 Azure DevOps(托管代理)新手,正在尝试使用 Azure Pipelines 通过 Ant 构建我的 Java Web 应用程序 下面是管道文件 trigger: - azure-pi
我最近重新配置了 TeamCity 构建配置,以利用分支功能将相同的构建配置应用于同一存储库中的多个分支。 现在,我正在尝试设置一个自动构建脚本,该脚本可以从 TeamCity 中提取最新的工件,但仅
我通过 FFMPEG 和 OpenMAX 使用硬件编码。 如果我使用 FFmpeg h264_omx 作为 VideoWriter 的后端,我会得到图像 like this .颜色显然有点混合。 其他
我有一个 iPhone 应用程序,它有一个基于 TableView 的数据输入屏幕,带有一个切换开关,打开时会显示表格另一部分中的所有行。 有时,当应用程序首次加载时,通常是当它从手机中完全删除时,除
我在每次构建结束时归档工件。我有 https://wiki.jenkins-ci.org/display/JENKINS/Archived+Artifact+Url+Viewer+PlugIn安装。
我在 vsreport 虚拟模式下使用 ListView ,有两列,在填充列表后,选择一行,然后选择其他行,之前选择的行上留下了一个工件,请参见下图。如何解决这个问题? 这是我从数组获取数据的代码 p
我有一个巨大的遗留 EAR 项目。当前的构建过程使用 Ant,我正在尝试转换为 gradle。 旧的 Ant 构建使用单个源文件夹,所有内容都在其中(EJB 和 WAR 代码一起);然后 Ant 使用
我们有一个 ivy 存储库,我们使用 gradle 进行依赖管理和构建框架。当一个工件被确定为生产就绪时,我们不想再次构建它,所以我们只想通过一个利用 Gradle 和工具 API 来完成大部分工作的
我有一个 gradle 构建,它必须将预构建的 jar 文件发布为工件。由于某种原因,它没有被拾取。这是重现它的简化版本: 文件夹内容: settings.gradle build.gradle so
是否有人编写过一个查询来同时监视所有 BizTalk 工件。 我的查询不起作用,而且我似乎无法完成它: 这是我的: select RL.Name AS rlName , ('Url:
我最近学习了如何使用 grailsApplication.addArtefact(java.lang.String artefactType, GrailsClass artefactGrailsCl
我想在 Bamboo 构建结束时运行内联脚本任务,以将一些工件复制到网络共享。请问如何在此脚本中引用工件输出目录? Windows 环境(如果这有影响的话)。 最佳答案 您需要configure Ar
我想要一个工件名称,例如game-1.0.%BuilNumber%.jar 其中 BuildNumber 是 teamcity 构建的编号。 我正在使用 gradle 来构建工件。使用该工具是否可行,
在 SBT 中,如果我有一个任务要生成包含一堆文件的 zip/jar/war,我会使用 Defaults.packageTaskSettings 方法来设置该任务。它看起来如下: object Bui
我一直在使用 TeamCity 来启动和运行 CI 环境。 我开始关注 Troy Hunt 的 'You're deploying wrong' ,这非常有用,但是我想将打包和部署分成 2 个单独的步
故事 我已经在 OpenGL 中编码大约一年了(在相同的硬件上),我最近才得到像上图中那样的工件。它们在短时间内(几分钟)连续运行我的程序后出现,并出现在任何地方:从写字板(见图片)到我的桌面和任务栏
我使用以下代码在代码中创建了一个 UITableView: // no xib tableView = new UITableView( new RectangleF(0,0, this.View.F
我是一名优秀的程序员,十分优秀!