My app has several UITextFields, it is working fine on iOS 13. But on iOS 14, when touch those UITextField, nothing would happen. I put break point on textFieldShouldBeginEditing, which it should be called first when touch based on the document. But this function was not called. I checked the UITextField, it's isEnabled and isUserInteractionEnabled both are true. How should I debug this issue and what could be the reason why textFieldShouldBeginEditing is not called?
iOS 14 UITextFieldDelegate's textFieldShouldBeginEditing not being called
More information about the issue I have. First I want to mention that each UITextField is inside a UITableViewCell. In my app, I override the function sendEvent( event: UIEvent). Inside sendEvent( event: UIEvent) just calls super.sendEvent(event). So I can put a break point and exam the UIEvent Object. What I found is that when I touch UITextField, for iOS 13, the UIEvent is <UITouchesEvent: 0x6000009757c0> timestamp: 12516 touches: {(
<UITouch: 0x7f9470936d70> phase: Began tap count: 1 force: 0.000 window: <UIWindow: 0x7f9468e21aa0; frame = (0 0; 375 667); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.188235 0.298039 0.698039 1; gestureRecognizers = <NSArray: 0x6000036e3ab0>; layer = <UIWindowLayer: 0x600003820c20>> view: <ROAM___Development.CustomTextField: 0x7f946c08a000; baseClass = UITextField; frame = (18 37; 357 40); text = ''; opaque = NO; tag = 1; gestureRecognizers = <NSArray: 0x6000037c2370>; layer = <CALayer: 0x600003f81120>> location in window: {154, 184.5} previous location in window: {154, 184.5} location in view: {136, 23.5} previous location in view: {136, 23.5}
)}
But for iOS 14, the UIEVent is
<UITouchesEvent: 0x283ef4180> timestamp: 21412.1 touches: {(
<UITouch: 0x110f16f60> phase: Ended tap count: 1 force: 0.133 window: <UIWindow: 0x10ec1f4f0; frame = (0 0; 375 667); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.188235 0.298039 0.698039 1; gestureRecognizers = <NSArray: 0x280569b00>; layer = <UIWindowLayer: 0x280bd6b00>> view: <UITableViewCellContentView: 0x10ec94220; frame = (0 0; 375 80); gestureRecognizers = <NSArray: 0x28049cfc0>; layer = <CALayer: 0x280c8b6c0>> location in window: {219.5, 172} previous location in window: {219.5, 172} location in view: {219.5, 48} previous location in view: {219.5, 48}
)}
So for iOS 13, I could see baseClass = UITextField. but not for iOS 14, the view for iOS 14 is UITableViewCellContentView. So somehow for iOS 14, when I touch the UITextField, the event is from the parent view UITableViewCellContentView. That may explain why UITextFieldDelegate call back function is not being called. But I am not sure why it doesn't generate UITextField event. Any help will be appreciated.
<UITouch: 0x7f9470936d70> phase: Began tap count: 1 force: 0.000 window: <UIWindow: 0x7f9468e21aa0; frame = (0 0; 375 667); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.188235 0.298039 0.698039 1; gestureRecognizers = <NSArray: 0x6000036e3ab0>; layer = <UIWindowLayer: 0x600003820c20>> view: <ROAM___Development.CustomTextField: 0x7f946c08a000; baseClass = UITextField; frame = (18 37; 357 40); text = ''; opaque = NO; tag = 1; gestureRecognizers = <NSArray: 0x6000037c2370>; layer = <CALayer: 0x600003f81120>> location in window: {154, 184.5} previous location in window: {154, 184.5} location in view: {136, 23.5} previous location in view: {136, 23.5}
)}
But for iOS 14, the UIEVent is
<UITouchesEvent: 0x283ef4180> timestamp: 21412.1 touches: {(
<UITouch: 0x110f16f60> phase: Ended tap count: 1 force: 0.133 window: <UIWindow: 0x10ec1f4f0; frame = (0 0; 375 667); autoresize = W+H; tintColor = UIExtendedSRGBColorSpace 0.188235 0.298039 0.698039 1; gestureRecognizers = <NSArray: 0x280569b00>; layer = <UIWindowLayer: 0x280bd6b00>> view: <UITableViewCellContentView: 0x10ec94220; frame = (0 0; 375 80); gestureRecognizers = <NSArray: 0x28049cfc0>; layer = <CALayer: 0x280c8b6c0>> location in window: {219.5, 172} previous location in window: {219.5, 172} location in view: {219.5, 48} previous location in view: {219.5, 48}
)}
So for iOS 13, I could see baseClass = UITextField. but not for iOS 14, the view for iOS 14 is UITableViewCellContentView. So somehow for iOS 14, when I touch the UITextField, the event is from the parent view UITableViewCellContentView. That may explain why UITextFieldDelegate call back function is not being called. But I am not sure why it doesn't generate UITextField event. Any help will be appreciated.
I´m not totally sure, if it helps. I had the problem with a UIButton in UITableviewCell and no Touchupinside / Tap events received.
The reason for that is probably:
medium.com/@dragos.rotaru9/uitableviewcell-in-ios-14-ef19e877319f
and in my case helped :
https://stackoverflow.com/questions/63987896/problem-with-gesture-in-xcode-12-and-ios-14
The reason for that is probably:
medium.com/@dragos.rotaru9/uitableviewcell-in-ios-14-ef19e877319f
and in my case helped :
https://stackoverflow.com/questions/63987896/problem-with-gesture-in-xcode-12-and-ios-14
If you are adding subviews to your cell programmatically and in custom cell if you have something like this:
[self addSubview:valueTF];
then replace it with
[self.contentView addSubview:valueTF];
all subviews to a cell should be added to contentView to receive the delayed callbacks.
[self addSubview:valueTF];
then replace it with
[self.contentView addSubview:valueTF];
all subviews to a cell should be added to contentView to receive the delayed callbacks.