为儿童制作的 iOS 应用程序,特别是那些在 App Store 的 "儿童馆" 部分的,必须有一个 家长控制,限制儿童无意识地访问设置、跟随链接到可能不安全的内容,或在应用内进行其他购买的能力。
ParentalGate
类是一个简单的、UI 模态的、类似于 UIAlertView
的家长控制,需要孩子阅读有关在一个方向上有指手势操作如何滑动手指方向以继续的说明。任何错误的点击或滑动都会关闭家长控制,并可选择让您的代码知道用户未能证明自己是成年人。
如果愿意,该类适用于所有 iPhone、iPod 和 iPad,直到 iOS 4.3。它处理所有肖像、横幅、倒置方向以及实时方向变化。
提供的示例/测试应用程序
UI 展示是一个相当通用的“不要进入”符号,该应用程序带有英语、西班牙语、法语和中文的本地化。如果您进行其他本地化,请随时提交拉取请求(请确保测试您的文本是否适合“不要进入”标识)。
#import "ParentalGate.h"
ParentalGate *myParentalGate;
myParentalGate = [ParentalGate newWithCompletion:^(BOOL success){
// this is your code which runs when the gate is dismissed
if (success) {
// the user has proven they are not a child
} else {
// the user has not proven they are a child
}
}];
[myParentalGate show];
或者在用户未能证明自己是成年人且无需执行任何操作时
[ParentalGate showWithSuccess:^{
// this block will only run if the user proves they are not a child
}];
要运行示例项目,克隆仓库,然后首先从 Example 目录运行 pod install
。
无。ParentalGate 是一个独立的 UIAlertView
-like UIView
类,仅使用 UIKit
。
Nat Brown,[email protected]
ParentalGate 可在 MIT 许可下使用。有关更多信息,请参阅 LICENSE 文件。