xaviermerino / XMSegmentedControl

A customizable segmented control with Icons, Text or Icons + Text segments. It is fully customizable and supports several inbuilt styles for displaying the selected segment. Written in Swift for iOS.
MIT License
193 stars 61 forks source link

Error adding segmented controller #31

Closed cdepace closed 7 years ago

cdepace commented 7 years ago

I'm trying to add a segmented control using this code:

        // add custom segmented control
        self.cSegControl = XMSegmentedControl(frame:tableHeaderAbsFrame, segmentTitle: ["one", "two", "three"], selectedItemHighlightStyle: XMSelectedItemHighlightStyle.BottomEdge)
        cSegControl.backgroundColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)
        cSegControl.highlightColor = UIColor(red: 255/255, green: 0/255, blue: 91/255, alpha: 1)
        cSegControl.tint = UIColor.black
        cSegControl.highlightTint = UIColor.black
        cSegControl.delegate = self
        self.view.addSubview(cSegControl)

but I get this error

2017-03-06 17:50:39.664 MyAPP[56793:9977216] -[XMSegmentedControl.XMSegmentedControl segmentPressed:]: unrecognized selector sent to instance 0x7fb9a0d7bc00 2017-03-06 17:50:39.674 MyAPP[56793:9977216] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[XMSegmentedControl.XMSegmentedControl segmentPressed:]: unrecognized selector sent to instance 0x7fb9a0d7bc00' First throw call stack:

not sure why the tap events don't get handled.

xaviermerino commented 7 years ago

Are you implementing the delegate in the view controller that hosts the segmented control?

Sent from my iPhone

On Mar 6, 2017, at 12:55 PM, cdepace notifications@github.com wrote:

I'm trying to add a segmented control using this code:

    // add custom segmented control
    self.cSegControl = XMSegmentedControl(frame:tableHeaderAbsFrame, segmentTitle: ["one", "two", "three"], selectedItemHighlightStyle: XMSelectedItemHighlightStyle.BottomEdge)
    cSegControl.backgroundColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)
    cSegControl.highlightColor = UIColor(red: 255/255, green: 0/255, blue: 91/255, alpha: 1)
    cSegControl.tint = UIColor.black
    cSegControl.highlightTint = UIColor.black
    cSegControl.delegate = self
    self.view.addSubview(cSegControl)

but I get this error

2017-03-06 17:50:39.664 MyAPP[56793:9977216] -[XMSegmentedControl.XMSegmentedControl segmentPressed:]: unrecognized selector sent to instance 0x7fb9a0d7bc00 2017-03-06 17:50:39.674 MyAPP[56793:9977216] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[XMSegmentedControl.XMSegmentedControl segmentPressed:]: unrecognized selector sent to instance 0x7fb9a0d7bc00' First throw call stack:

not sure why the tap events don't get handled.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

cdepace commented 7 years ago

Yes, I solved copy/pasting the XMSegmentedControl.swift file from the example directly to my project. Integrating the pod was giving this error.

xaviermerino commented 7 years ago

Oh that is weird. I thought that was fixed. Thanks for letting me know!