PAPasscode是一个用于iOS的自立视图控制器,允许用户设置、输入或更改密码。它旨在模仿Settings.app中的行为,同时允许一些自定义。它包括一个示例项目,演示了在iPhone和iPad设备上的显示方式。
其他功能
将PAPasscode添加到您的项目最简单的方法是使用CocoaPods。只需在Podfile中添加以下行
pod 'PAPasscode'
如果您更愿意手动集成,只需将PAPasscode/*.{m,h}
和Assets/*.png
复制到您的项目中。请确保与QuartzCore框架链接。
首先,在您的视图控制器中实现以下代理方法
- (void)PAPasscodeViewControllerDidCancel:(PAPasscodeViewController *)controller {
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)PAPasscodeViewControllerDidSetPasscode:(PAPasscodeViewController *)controller {
// Do stuff with controller.passcode...
[self dismissViewControllerAnimated:YES completion:nil];
}
然后按照以下方式调用视图控制器
PAPasscodeViewController *passcodeViewController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionSet];
passcodeViewController.delegate = self;
[self presentViewController:[[UINavigationController alloc] initWithRootViewController:passcodeViewController] animated:YES completion:nil];
initForAction:
函数允许您指定所需的流程。可能的行为有
PasscodeActionSet
- 设置新密码PasscodeActionEnter
- 输入现有密码PasscodeActionChange
- 更改现有密码所包含的示例项目演示了每个流程。
PAPasscodeViewControllerDidCancel:
代理方法是可选的。如果不存在,则取消按钮将被移除。有关此库和其他库的更新,请关注我的Twitter(@denishennessy)或App.net(@denishennessy)。
如果您遇到错误或想到了很酷的新特性,那么打开github问题可能是分享的最佳方式。实际上,最好的方式是发给我一个pull request...
对于其他任何问题,电子邮件始终有效:[email protected]
Copyright (c) 2012-2015, Denis Hennessy (Peer Assembly - http://peerassembly.com)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Peer Assembly, Denis Hennessy nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL PEER ASSEMBLY OR DENIS HENNESSY BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.