gpt4 book ai didi

ios - 在 CNContactPickerViewController 中隐藏或禁用搜索栏

转载 作者:搜寻专家 更新时间:2023-10-31 23:09:21 28 4
gpt4 key购买 nike

我了解到 CNContactPickerViewController 中的搜索栏不允许选择搜索到的联系人。我还查看了有关此问题的其他堆栈溢出问题。这似乎是 iOS 错误。但我想知道,有什么方法可以隐藏或禁用 CNContactPickerViewController 的搜索栏吗?因为如果这不起作用,那么我不想展示它。

最佳答案

private var foundSearchBar: Bool = false

func findSearchBar(_ parent: UIView, mark: String) {
for v: UIView in parent.subviews {
//if( foundSearchBar ) return;
print("\(mark)\(NSStringFromClass(v.self))")
if (v is UISearchBar) {
(v as? UISearchBar)?.tintColor = UIColor.black
v.hidden = true
// foundSearchBar = YES;
break
}
if (v is UITableView) {
let temp: CGRect = v.frame
temp.origin.y = temp.origin.y - 44
temp.size.height = temp.size.height + 44
v.frame = temp
//foundSearchBar = YES;
break
}
findSearchBar(v, mark: mark + ("> "))
}
}

选择器出现后调用上述方法如下:

func showPeoplePickerController() {
let picker = ABPeoplePickerNavigationController()
picker.peoplePickerDelegate = self
picker.view.autoresizingMask = .flexibleHeight
// Display only a person's phone, email, and birthdate
let displayedItems: [Any] = [Int(kABPersonPhoneProperty), Int(kABPersonEmailProperty), Int(kABPersonBirthdayProperty), Int(kABPersonAddressProperty)]
picker.displayedProperties = displayedItems
// Show the picker
present(picker, animated: true) { _ in }
findSearchBar(picker.view(), mark: "> ")
}

关于ios - 在 CNContactPickerViewController 中隐藏或禁用搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45228591/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com