From 36cb048aa1a0590c2e5bb19a7ec94ef32a0fcbd1 Mon Sep 17 00:00:00 2001 From: fish Date: Mon, 20 Jul 2026 21:43:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=AE=E7=9B=98=E4=B8=8A=E6=96=B9=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=A1=AE=E8=AE=A4=E6=8C=89=E9=92=AE=EF=BC=8C=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E9=AA=8C=E8=AF=81=E6=8B=BC=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- .../Views/QuizViewController.swift | 3 +++ .../LearnEnglish/Views/SpellingInputView.swift | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/LearnEnglish/LearnEnglish/Views/QuizViewController.swift b/LearnEnglish/LearnEnglish/Views/QuizViewController.swift index b20a010..7827180 100644 --- a/LearnEnglish/LearnEnglish/Views/QuizViewController.swift +++ b/LearnEnglish/LearnEnglish/Views/QuizViewController.swift @@ -234,6 +234,9 @@ final class QuizViewController: UIViewController { nextButton.isEnabled = false nextButton.isHidden = false } + spellingView.onSubmit = { [weak self] in + self?.primaryButtonTapped() + } spellingView.activate() } else if isDictation { dictationView.reset() diff --git a/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift b/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift index 639206d..6bab347 100644 --- a/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift +++ b/LearnEnglish/LearnEnglish/Views/SpellingInputView.swift @@ -2,6 +2,7 @@ import UIKit final class SpellingInputView: UIView, UITextFieldDelegate { var onChange: (() -> Void)? + var onSubmit: (() -> Void)? private let hiddenField = UITextField() private let stack = UIStackView() @@ -56,6 +57,23 @@ final class SpellingInputView: UIView, UITextFieldDelegate { hiddenField.frame = .zero addSubview(hiddenField) + let accessory = UIView() + accessory.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 52) + accessory.backgroundColor = .clear + let confirmButton = UIButton(type: .system) + confirmButton.setTitle("确认", for: .normal) + confirmButton.titleLabel?.font = .systemFont(ofSize: 17, weight: .semibold) + confirmButton.addAction(UIAction { [weak self] _ in + self?.onSubmit?() + }, for: .touchUpInside) + confirmButton.translatesAutoresizingMaskIntoConstraints = false + accessory.addSubview(confirmButton) + NSLayoutConstraint.activate([ + confirmButton.trailingAnchor.constraint(equalTo: accessory.trailingAnchor, constant: -8), + confirmButton.topAnchor.constraint(equalTo: accessory.topAnchor, constant: 8) + ]) + hiddenField.inputAccessoryView = accessory + addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(reactivate))) }