问题描述
我需要使用以下方法获取 tabBar 中 imageView 的框架以及 navigationBarButtonItem 的框架:
let fifthTab = tabBarController?.tabBar.items?[4].value(forKey: "view") as? UIView { ... }
let barButtonItemView = self.navigationItem.rightBarButtonItem?.value(forKey: "view") as? UIView { ... }
在这两种情况下,我都成功地根据它们的框架设置了一些其他 UIView。我读到它们是私有 API,使用私有 API 会导致 AppStore 被拒绝,但我发现了很多在 SO 和 GitHub 之间使用它们的示例。没有人确认这些在 AppStore 上线时是否会导致拒绝。
有人可以确认使用这些 API 会导致拒绝吗?
解决方法
这取决于苹果。但基本上不会被拒绝。 Apple 有一个特殊的私有 API 扫描器来检测您是否使用敏感 API。虽然 valueForKey 和 view 是相当常见且合法的 API,但扫描器很难扫描它们。