gpt4 book ai didi

ios - 调用 `[UISearchBar setReturnKeyType:]` 时无法识别的选择器

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:13:16 25 4
gpt4 key购买 nike

在我们的应用程序中,我们开始为 iOS 7.0、7.0.4 和 7.0.6 用户收到以下错误:

-[UISearchBar setReturnKeyType:]: 无法识别的选择器发送到实例 0x178a7920

我们花了一些时间才弄清楚发生了什么,因为 Xcode 6.4 不再支持 7.0、7.0.4 和 7.0.6 模拟器。下面分享解释。

最佳答案

我们从 UISearchBar.h 中的文档中了解到:

...UISearchBar officially conformed to UITextInputTraits in iOS 8.0 and privately conformed in iOS 7.0...

因此 8.x 对 UITextInputTraits 有公开/完全支持,但 iOS 7.x 版本仅对它有私有(private)/可能部分支持。

我们开始尝试不同的 iOS 7.x 版本,发现等于或高于 iOS 7.1 的版本支持 setReturnKeyType:,而早期版本不支持。

好像a different method在 iOS 7 的早期版本中使用(请参阅链接中第二受欢迎的答案),这似乎验证了我们的结论。

所以对于 iOS 7.x 版本,我们最终使用了这个:

if ([searchBar respondsToSelector:@selector(setReturnKeyType:)]) {
searchBar.returnKeyType = UIReturnKeyDone; // Pick a type
} else {
// Call the method from the linked answer above for iOS < 7.1
// or leave the return key type unchanged.
}

关于ios - 调用 `[UISearchBar setReturnKeyType:]` 时无法识别的选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31996624/

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