-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BonMot disables IBActions dragging from storyboard #252
Comments
@leojkwan thanks for reporting this. I was able to reproduce your issue, but I can't figure out what to comment out in order to get buttons to be able to send events again. What did you comment to get it to work? |
Hi @ZevEisenberg, Just comment out all extensions of UIButton in Bon Mot framework, theres at least three places that have them. |
//extension UIButton: StyleableUIElement {
//
// /// The name of a style in the global `NamedStyles` registry. The getter
// /// always returns `nil`, and should not be used.
// @IBInspectable
// public var bonMotStyleName: String? {
// get { return nil }
// set {
// guard let font = titleLabel?.font else { fatalError("Unable to get the font. This is unexpected; see UIKitTests.testTextFieldPropertyBehavior") }
// bonMotStyle = lookUpSharedStyle(for: newValue, font: font)
// }
// }
//
// /// A string style. Stored via associated objects.
// public final var bonMotStyle: StringStyle? {
// get { return getAssociatedStyle() }
// set {
// setAssociatedStyle(bonMotStyle: newValue)
// styledText = titleLabel?.text
// }
// }
//
// /// Update this property to style the incoming text via the `bonMotStyle`
// /// and set it as the receiver's attributed text for the "normal" state.
// @objc(bon_styledText)
// public var styledText: String? {
// get { return titleLabel?.text }
// set {
// let styledText = styledAttributedString(from: newValue)
// setAttributedTitle(styledText, for: .normal)
// }
// }
//
//}
// extension UIButton {
//
// @nonobjc final func setAttributedTitle(title: NSAttributedString?, for state: UIControlState) {
// setAttributedTitle(title, forState: state)
// }
//
// }
//extension UIButton: AdaptableTextContainer {
//
// /// Adapt `attributedTitle`, for all control states, to the specified trait collection.
// ///
// /// - parameter traitCollection: The new trait collection.
// @objc(bon_updateTextForTraitCollection:)
// public func adaptText(forTraitCollection traitCollection: UITraitCollection) {
// for state in UIControlState.commonStates {
// #if swift(>=3.0)
// let attributedText = attributedTitle(for: state)?.adapted(to: traitCollection)
// setAttributedTitle(attributedText, for: state)
// #else
// let attributedText = attributedTitleForState(state)?.adapted(to: traitCollection)
// setAttributedTitle(attributedText, forState: state)
// #endif
// }
// }
//
//}
|
I am experiencing the same issue in xCode 8.2. |
Has anyone been able to find a fix, other than just commenting out the offending code? We don't use IB much at Raizlabs, which is why we didn't catch this. |
@ZevEisenberg Agreed. Instead of commenting out the protocol extensions for UIButton, we can subclass UIButton and provide the protocol extensions to the subclass. The subclass will just be an empty declaration, and any existing buttons referencing the UIButton extension methods on BonMot will have to subclass this interface. I don't know why this bug is happening, but I think it's worth the quick fix as I suspect there are a ton of projects using BonMot with at least 1 @IBAction from a UIButton from Storyboard.
|
I've fixed this in situ in my own project by unlocking the pod. |
I think I have it fixed, but i cloned instead of forking. Pull request incoming within the hour! |
I was also wondering whether doing the extension in Objective-C might work, but I haven't explored it much. I'd prefer to avoid subclassing if possible. |
The subclassing solution is almost working in my fork, just working on getting the tests passing. |
I would prioritize pragmatism (Objective-C) over purity (pure Swift). This project is so tightly bound to UIKit/AppKit that there's not much benefit in avoiding Objective-C, since you're not going to be able to use it on Linux without NSAttributedString and its platform-specific dependencies anyway. |
Hello, we just ran into this on our new project. Right now we are commenting this out, because we dont really use it at the moment, but I was wandering if a fix is actively being pursued at the moment. I see there was some progress recently, but that its still not assigned. What I can offer is that this issue affects all the controls, not just the button. Adding any protocol to an extension of the apple provided base class causes this: https://forums.developer.apple.com/thread/25180 |
yep same problem in xcode 8.2.1 👎 please give a solution |
We really need a fix for this. BonMot is such a beauty, but right now all IBActions are disabled :( |
Sorry for the continued inconvenience, everyone! I've been on vacation for the last few days. I'm going to put some time into this and see what I can dig up, or try to track down someone at Apple who knows what's up. Thanks for your continued patience. As a workaround, you can assign actions in code. It stinks, but it should keep your code shippable until we get this solved :( |
There were some radars filed on that Apple thread, but I filed my own so I can keep this thread updated if I hear any updates: http://openradar.me/30001713 Still working on a fix or workaround. |
Sorry again for the delay. If you've been seeing this problem, please try the fix from #259 and let us know if it works for you. We should be able to get it merged pretty soon. |
This is now fixed in 4.0.2. Try it out and let us know if you find any problems! |
Awesome, it's fixed now in 4.0.2. Thank you very much sir, and again, really awesome lib :) |
When Bonmot is included in my project, all my UIButton 'Touch Up Inside' events in the connections inspector via Utilities show warning signs. I suspect it has something with this stack overflow issue: http://stackoverflow.com/questions/28732903/cant-connect-ibaction-in-xcode.
As one of the commenters suggested in the link, the culprit seems to be the UIButton extensions in BonMot's framework.
I commented the several extensions for UIButton out and now it works fine.
Going to work with clone bonmot into own project in meantime, but would love for this to be addressed!
The text was updated successfully, but these errors were encountered: