Skip to content
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

didSelectSegmentAtindex #16

Closed
HideCode7 opened this issue Mar 22, 2016 · 8 comments
Closed

didSelectSegmentAtindex #16

HideCode7 opened this issue Mar 22, 2016 · 8 comments

Comments

@HideCode7
Copy link

HI great project, but i have a problem.
I copy your code from my project and i put the segment on mapkit, and when i click in segment, method didSelectSegmentAtIndex, it is not called.

I update xcode from 7.3

@sima-11
Copy link
Owner

sima-11 commented Mar 22, 2016

@HideCode7 If this is the delegate method that you called:
func segmentView(segmentView: SMBasicSegmentView, didSelectSegmentAtIndex index: Int){}
then probably you forgot to assign the delegate property?

@HideCode7
Copy link
Author

I have this

`class ParkingPaymentGeo: UIViewController, SMSegmentViewDelegate, CLLocationManagerDelegate, MKMapViewDelegate {
var segmentView: SMSegmentView!
var margin: CGFloat = 10.0

override func viewDidLoad() {
    super.viewDidLoad()

    self.segmentView = SMSegmentView(frame: CGRect(x: self.margin, y: 120.0, width: self.view.frame.size.width - self.margin*2, height: 40.0), separatorColour: UIColor(white: 0.95, alpha: 0.3), separatorWidth: 0.5, segmentProperties: [keySegmentTitleFont: UIFont.systemFontOfSize(12.0), keySegmentOnSelectionColour: UIColor(red: 245.0/255.0, green: 174.0/255.0, blue: 63.0/255.0, alpha: 1.0), keySegmentOffSelectionColour: UIColor.whiteColor(), keyContentVerticalMargin: 10.0])

    self.segmentView.delegate = self

    self.segmentView.layer.cornerRadius = 5.0
    self.segmentView.layer.borderColor = UIColor(white: 0.85, alpha: 1.0).CGColor
    self.segmentView.layer.borderWidth = 1.0

    // Add segments
    self.segmentView.addSegmentWithTitle("Clip", onSelectionImage: UIImage(named: "car"), offSelectionImage: UIImage(named: "car"))
    self.segmentView.addSegmentWithTitle("Blub", onSelectionImage: UIImage(named: "walk"), offSelectionImage: UIImage(named: "walk"))
    self.segmentView.addSegmentWithTitle("Cloud", onSelectionImage: UIImage(named: "bike"), offSelectionImage: UIImage(named: "bike"))
    // Set segment with index 0 as selected by default
    //segmentView.selectSegmentAtIndex(0)

    self.view.addSubview(self.segmentView)
}

// SMSegment Delegate
func didSelectSegmentAtIndex(segmentIndex: Int) {
            print("Select segment at index: \(segmentIndex)")
}`

@sima-11
Copy link
Owner

sima-11 commented Mar 22, 2016

@HideCode7 The name of the delegate method is not right. The one in your code is an old version of it. Try using this:
func segmentView(segmentView: SMSegmentView, didSelectSegmentAtIndex index: Int) {
print("Select segment at index: (index)")
}

@HideCode7
Copy link
Author

If i used your solution i have this error:

Type 'ParkingPaymentGeo' does not conform to protocol 'SMSegmentViewDelegate'

@sima-11
Copy link
Owner

sima-11 commented Mar 23, 2016

@HideCode7 It looks like you're using an old version of this framework. Maybe try re-downloading it?

@HideCode7
Copy link
Author

@allenbryan11 I donwload your project again is it?

@sima-11
Copy link
Owner

sima-11 commented Mar 23, 2016

@HideCode7 The delegate method has been changed to the one that I mentioned above months ago. So if the compiler complaints about using it, it should because that the framework is not up-to-date.

@HideCode7
Copy link
Author

Yes i have the a new donload of your project and now it is update :).
Problem solved.

Keep up the good work and thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants