Open lumanmann opened 5 years ago
Finally figure out the cause of #4
The primary cause the target is pointed to Toolbar instant instead of the view controller, where the selector is. If change the target to view controller, it will work totally fine.
When click on the Done button in the tool bar, there is no response.
Attempt 1
Inspecting maybe the selector is somehow lost when passing to the button Tried to open a Custom Toolbar class to see if it helps ViewController:
CustomToolBar:
Soon I received a error when running the app:
It appearances to be a problem of passing the selector.
The reason seems to be because the selector pass to view inside view.
Responder chain cannot get the right selector from the superview's superview.
Therefore there is no response or crash.
Attempt 2
As we cannot pass a selector to view inside view, I choose to use a callback instead.
Amended my code as follow:
ViewController:
TODO
Although callback can work, maybe better to figure out how to pass selector through views hierarchy. Some article may help: https://stackoverflow.com/questions/55555335/unrecognized-selector-sent-to-instance https://www.jianshu.com/p/60c251712df7 https://medium.com/@nguyenminhphuc/how-to-pass-ui-events-through-views-in-ios-c1be9ab1626b https://medium.com/ios-os-x-development/understanding-cocoa-and-cocoa-touch-responder-chain-12fe558ebe97