事の始まり
サービスの新規登録画面を作り直すことになりました。
内容としては簡単なもので、項目は以下の通り。
・メールアドレス入力
・パスワード入力
・パスワード再入力
UITextField
をパラパラっと設置して、キーボードのタイプを指定して、
最後にパスワードは見えないようにisSecureTextEntry
を忘れずに。
簡単ですね😀!!
class SignUpViewController: UIViewController {
@IBOutlet private weak var emailAddressText: UITextField!
@IBOutlet private weak var passwordText: UITextField!
@IBOutlet private weak var rePasswordText: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
emailAddressText.keyboardType = .emailAddress
emailAddressText.isSecureTextEntry = false
emailAddressText.textContentType = .emailAddress
passwordText.keyboardType = .asciiCapable
passwordText.isSecureTextEntry = true
passwordText.textContentType = .password
rePasswordText.keyboardType = .asciiCapable
rePasswordText.isSecureTextEntry = true
rePasswordText.textContentType = .password
}
}
動かしてみる&問題が見つかる
まずメールアドレス入力、次にパスワード入力、最後にパスワード再入力っと。
ん???
なんでパスワード再入力時にメールアドレス
、ユーザ名
のサジェストが出てくるんだ・・・🤔
しかもサジェストを選択するとメールアドレス
に入力されてフォーカスがパスワード入力に移動する😇
調査してみる
きっとtextContentType
が間違っているんだ!
と、いうことで色々組み合わせを変えてみる。
まずは何も指定しないケース
emailAddress | password | rePassword | |
---|---|---|---|
isSecureTextEntry | false | false | false |
textContentType | nil | nil | nil |
これは問題なし。サジェストは表示されず、想定通りの動き。
しかしパスワード丸見えなのでサービスとしては駄目。
次に色々と指定してみるケース
emailAddress | password | rePassword | |
---|---|---|---|
isSecureTextEntry | false | true | true |
textContentType | username | password | password |
emailAddress | password | rePassword | |
---|---|---|---|
isSecureTextEntry | false | true | true |
textContentType | nil | nil | nil |
emailAddress | password | rePassword | |
---|---|---|---|
isSecureTextEntry | false | false | false |
textContentType | username | password | password |
emailAddress | password | rePassword | |
---|---|---|---|
isSecureTextEntry | false | false | false |
textContentType | username | newpassword | newpassword |
emailAddress | password | rePassword | |
---|---|---|---|
isSecureTextEntry | false | false | false |
textContentType | username | password | password |
組み合わせとしては全部駄目でした。
サジェストが出てしまいフォーカスも意図しない動きになる。
どうやらisSecureTextEntry
、textContentType
をいじるとサジェストが出てしまうようだ・・・🤔
パラメータの組み合わせで解決するかなと思ったが駄目みたい。
教えてApple!!
というわけでApple Technical Support Incidentを投げてみました。
やりとりの内容としては以下の通りです。
筆者「UITextFieldを3つ置いてtextContentTypeとisSecureTextEntryを指定します。」
筆者「特定の組み合わせで意図しないサジェストが出てしまいます。解決方法はないでしょうか?」
Apple「問題を解決するため問題箇所に特化したサンプルプロジェクトを送って下さい。」
〜サンプルプロジェクトを送る〜
Apple「フィールドのキーボードの提案、またはプロジェクトが示す動作は、システムのバグと見なされます。(Google翻訳)」
Apple「Feedback Assistantでバグレポートを送って下さい。」
とのことでした。
おわりに
とりあえずバグレポートは作成して報告したので修正を待とうと思います。
今回初めてTSI投げましたが、解答が早く不具合もすぐ認めてくれたので正直びっくりしました。
以上です。