![](/img/trans.png)
[英]How can I support the up and down arrow keys with a Bluetooth keyboard under iOS 7
[英]Detect up/down arrow keys in UISearchBar so keyboard can be used to highlight search results
當我的 UISearchBar 是第一響應者時,如何檢測鍵盤上向上/向下箭頭鍵的按下? 我希望用戶能夠使用鍵盤來選擇搜索結果列表中的項目。
我已經嘗試在包含 UISearchBar 的視圖控制器中為向上/向下箭頭添加鍵命令,但是當 UISearchBar 是第一響應者時,這些方法永遠不會被調用。
這個功能在 Safari、Mail、Photos 和其他本地應用程序中是可能的——希望 Apple 沒有在那里使用某種私有 API。
當然,我在發布后立即找到了答案。 您必須在wantsPriorityOverSystemBehavior
UIKeyCommand
使命令在文本字段獲得焦點時起作用。
https://developer.apple.com/videos/play/wwdc2021/10260/?time=425
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.