// WORKS: 按钮可以点击
_mode = [UIButton buttonWithType:UIButtonTypeCustom];
_textField.rightView = _mode;
_textField.rightViewMode = UITextFieldViewModeAlways;
// NOT WORK: 不知道为什么不能处理这样的tap事件
_mode 是 UIImageView
然后在_mode上面 addTapGuesture.
本文探讨了在iOS开发中使用UIButton实现按钮点击事件处理,并通过添加UIImageView和tap gesture来处理触摸事件的过程。详细解释了如何配置按钮的右视图、视图模式以及触摸事件的实现。
// WORKS: 按钮可以点击
_mode = [UIButton buttonWithType:UIButtonTypeCustom];
_textField.rightView = _mode;
_textField.rightViewMode = UITextFieldViewModeAlways;
// NOT WORK: 不知道为什么不能处理这样的tap事件
_mode 是 UIImageView
然后在_mode上面 addTapGuesture.