I have tried to connect several buttons to a single IBAction in Xcode 8 however it does not work. I tried the practices outlined here Xcode8 cannot connect multiple/single uibuttons to single @IBAction in swift file still to no avail. can anyone shed some light as to why or if it is simply still just a bug?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
Works fine for me in Xcode 8.1 on a new Swift 3 project. You have to control-drag from the button to the center side of the method to select it if it already exists rather than drag to the left side.
I was able to resolve the issue by upgrading to Xcode 8.1 and including an _ before the sender argument. I believe this is just a bug from Xcode 8 because I tried the latter before upgrading and I was still unable to connect.
Double check if you want to add action to a real button Check if when you wrote the action, you used some customized class instead of UIButton, and the class of your button does not match.
change your parameter from (_ sender: Any) to (_ sender: UIButton), and you're good to go.
There is no reason why several buttons should not connect to a single action function in your code. I had no trouble doing this when I tried it, as you can see:
However, if the nib editor interface won't let you form the connection, configure the action-target of the buttons in code.