奇怪的 iPhone 应用程序启动问题
我正在应用程序中实现安全密码功能。该解决方案的一部分基于可在 GitHub 上找到的 PTPasscodeViewController 示例代码。我遇到的问题是,当应用程序首次启动并且输入 PIN 码时,UI 并未更新,每个框中都有一个圆圈。如果输入的 4 位 PIN 码不正确,则不会显示我的消息。就好像 runloop 没有被执行或者什么的。如果我输入正确的 PIN,应用程序就会按预期解锁。功能有效,但 UI 未更新。
一旦应用程序解锁,如果我进入“设置”(在应用程序中)并更改密码,点就会显示得很好,如果在 PIN 确认期间第二个 PIN 与第一个 PIN 不匹配,UI 也会正确更新。
此应用程序启用后台多任务处理。在 iOS 4.2.1 上,当应用程序再次激活时,将使用与首次启动应用程序时相同的 PIN 验证逻辑。唯一的区别是,这并不是真正的首次发布,而是从后台回归。在这种情况下,PIN 验证逻辑和 UI 工作正常......相同的代码正在执行。点和任何消息均正确显示。
但是,在 3.1.2 上,由于不支持后台多任务处理,因此应用程序始终从头开始启动。因此,每次启动应用程序时,功能都可以运行,但用户界面无法正确更新。
我一定对这里的某些东西有基本的误解,但不确定我不明白什么。有人能指出我正确的方向吗?
I'm implementing secure passcode functionality within the app. Part of the solution is based on the PTPasscodeViewController sample code that can be found on GitHub. The issue I am having is when the app is first launched and the PIN is typed the UI is not updated with a circle in each box. If the 4 digits of the PIN that was entered are incorrect my message isn't displaying. It's as if the runloop isn't getting executed or something. If I enter the correct PIN the app is unlocked as expected. The functionality works but the UI isn't updated.
Once the app is unlocked if I go into Settings (in the app) and change the passcode the dots show up just fine and if during PIN confirmation the second PIN does not match the first the UI is also updated correctly.
Background multitasking is enabled in this app. On iOS 4.2.1 when the app becomes active again the same PIN validation logic is used as when the app is first launched. The only difference is it isn't really the first lauch but a return from the background. In this case, the PIN validation logic AND UI works correctly... the same code is executing. The dots and any messages are correctly displayed.
However, on 3.1.2, since background multitasking is not supported the app is always launched from scratch. So every time the app is launched the functionality works but the UI fails to update properly.
I must have a basic misunderstanding of something here but not sure what it is that I don't get. Can anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己解决了这个问题,这是由于缺乏对 applicationDidBecomeActive 也在 applicationDidFinishLaunchingWithOptions 之后触发这一事实的结果。基本上,首次启动应用程序时,显示 PIN 验证屏幕的代码会连续执行两次。从 applicationDidFinishLaunchingWithOptions 中删除 PIN 验证启动并仅在 applicationDidBecomeActive 中调用它修复了该问题。
I resolved this issue myself and it was a result of a lack of understanding the fact that applicationDidBecomeActive also fires after applicationDidFinishLaunchingWithOptions. Basically the code to show the PIN validation screen was being executed twice in a row when lauching the app for the first time. Removing the PIN validation launch from applicationDidFinishLaunchingWithOptions and calling it only in applicationDidBecomeActive fixed it.