You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS 15下Swift开发无法禁用键盘autofill问题求解(Xcode 13)

iOS 15自动填充相关更新说明

iOS 15对自动填充的识别逻辑做了优化,系统不再仅依赖textContentType属性判断字段类型,还会结合输入框占位符、周边关联标签文本、字段排列规则等启发式规则做语义识别,因此原有仅设置textContentType = .none和autocorrectionType = .no的方案会失效。

iOS 15禁用自动填充适配方案

按以下优先级尝试适配即可:

  • 保留原有配置的基础上,新增智能输入相关属性的禁用配置,完整代码如下:
firstName.autocorrectionType = .no
lastName.autocorrectionType = .no
        
firstName.textContentType = .none
lastName.textContentType = .none 

// 新增iOS 15适配配置
firstName.smartQuotesType = .no
firstName.smartDashesType = .no
firstName.autocapitalizationType = .none

lastName.smartQuotesType = .no
lastName.smartDashesType = .no
lastName.autocapitalizationType = .none
  • 检查输入框的占位符、关联的说明文本是否包含「名字」「姓氏」「姓名」这类语义化表述,如有可以调整为无明确语义的内容,或修改输入框的accessibilityLabel为非语义化内容,避免被系统启发式识别命中。
  • 若以上方案仍不生效,可将输入框的keyboardType设置为.asciiCapable(仅适用于不需要输入中文的场景),进一步降低自动填充触发概率。

内容的提问来源于stack exchange,提问作者Houston

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 12:15:02