密码保护 iPhone 应用程序

发布于 2024-09-02 05:31:49 字数 408 浏览 4 评论 0 原文

我正在启动一个新应用程序,我想知道如何需要密码才能打开它。

我正在考虑在应用程序委托实现文件的应用程序 didFinishLaunchingWithOptions 方法中使用 UIActionSheet,但我不确定如何执行此操作。不过我会继续努力。

找到此视频,看起来很有帮助。

现在,我的 UIActionSheet 会弹出并显示“输入密码”,并且正在尝试弄清楚如何将键盘添加到操作表中。

I'm starting a new app, and I'd like to know how to require a password to open it.

I was considering a UIActionSheet in the application didFinishLaunchingWithOptions method of the app delegate implementation file, but am unsure how to go about doing so. I'm going to keep trying though.

Found this video, which seems pretty helpeful.

Now I've got my UIActionSheet to pop up displaying "Enter password," and am trying to figure how to add a keypad to the action sheet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

凉薄对峙 2024-09-09 05:31:49

我认为使用完整的 UIViewController 实例而不是 UIActionSheet 可能会更好。将键盘行为添加到操作表中即使不是不可能,也是很困难的。

如果您创建 UIViewController 子类,则可以让您的应用程序委托将其呈现在 -application:didFinishLaunchingWithOptions: 中。假设您在主界面中使用某种 UIViewControllerUINaviagtionController,您可以使用 UIViewController 在启动时以模态方式呈现密码视图控制器-presentModalViewController:animated:

拥有密码视图控制器后,您需要添加一个 UITextField 来输入密码。使文本字段成为 firstResponder (通过调用 becomeFirstResponder ),这将导致显示键盘。您可能还需要在文本字段上设置 keyboardAppearance 属性来控制键盘的显示方式,例如,如果您想要限制为数字 PIN 与完整密码。设置 secureTextEntry 属性也可能有助于防止显示实际密码。有关这两个选项,请参阅 UITextField 上的 UITextInputTraits 协议。

为了确保应用程序的安全,您将创建密码视图控制器,以便它除了“提交”或“登录”类型按钮之外没有任何按钮或导航选项。如果用户输入正确的密码,您将关闭模态视图控制器并让他们进入。如果他们不知道密码,他们唯一的选择就是点击“主页”按钮退出您的应用程序,因为他们将无法继续超越模态视图控制器。

I think you may have better luck using a full UIViewController instance instead of a UIActionSheet. Adding keyboard behavior to an action sheet will be difficult if not impossible.

If you create a UIViewController subclass, you can make your application delegate present it in -application:didFinishLaunchingWithOptions:. Assuming you're using some sort of UIViewController or UINaviagtionController for your main interface, you could have the password view controller presented modally at startup using UIViewController-presentModalViewController:animated:.

Once you have your password view controller, you'll need to add a UITextField for password entry. Make the text field become firstResponder (by calling becomeFirstResponder on it), and that will cause the keyboard to be displayed. You may also want to set the keyboardAppearance property on the text field to control how the keypad appears if for example you want to limit to a numeric PIN versus a full password. Setting the secureTextEntry property may also be desirable to prevent the actual password from being display. See the UITextInputTraits protocol on UITextField for both of those options.

In order to make the app secure, you would create your password view controller so that it has no buttons or navigation options other than a "Submit" or "Login" type button. If the user enters the correct password, you dismiss the modal view controller and let them in. If they don't know the password, their only choice is to tap the Home button to exit your application as they'd have no way to proceed beyond the modal view controller.

清风不识月 2024-09-09 05:31:49

认为存储库 http://github.com/lashad/PTPasscodeViewController 对于访问此页面的人可能有用。

Thought the repo http://github.com/lashad/PTPasscodeViewController could be useful for someone visit this page.

阳光下的泡沫是彩色的 2024-09-09 05:31:49

UIAlertView 怎么样?但我不知道该应用程序是否会被拒绝。一些人说是,其他人说不是。不知道过去的事情有没有改变。

以下是一些链接:

http://junecloud.com/journal/code/displaying-a-password-or-text-entry-prompt-on-the-iphone.html

iPhone 上 UIAlertView 中的 UITextField - 如何使其响应?

http://iphone-dev-tips.alterplay.com/2009/ 12/用户名和密码-uitextfields-in.html

http://discussions.apple.com/thread.jspa?threadID=1674641&start=15&tstart=0

http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting -a-uitextfield-in-a-uialertview/

大多数链接的作用相同,它们都使用CGAffineTransformMakeTranslation。有人说iOS 4不需要这个。而且有时会出现问题。没有尝试,因为我不想被拒绝......

What about a UIAlertView? But I don't know if the app gets rejected or not. A few say yes, the other no. Doesn't know if things changed in the past.

Here are some links:

http://junecloud.com/journal/code/displaying-a-password-or-text-entry-prompt-on-the-iphone.html

UITextField in UIAlertView on iPhone - how to make it responsive?

http://iphone-dev-tips.alterplay.com/2009/12/username-and-password-uitextfields-in.html

http://discussions.apple.com/thread.jspa?threadID=1674641&start=15&tstart=0

http://icodeblog.com/2009/11/09/iphone-coding-tutorial-inserting-a-uitextfield-in-a-uialertview/

Most of the links do the same, they all use CGAffineTransformMakeTranslation. Someone stated that this isn't needed for iOS 4. And sometimes there are problems. Didn't tried it out, because I don't want to get rejected ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文