Based on what you said in the comments, I would like to write it in a conclusive way.
UISegmentedControl
Properties selectedSegmentedIndex
are correctly oriented.Value of type' (UISegmentedControl)'->() has no member 'selectedSegmentedIndex'
error is most likely incorrectly declared on self.xxx
.For your information, I will list all the code for the ViewController that I created for verification purposes.
import UIKit
classViewController:UIViewController {
@IBOutlet weak var segmentedControl:UISegmentedControl!
@ IBAction func buttonPressed (sender: UIButton) {
let index = sender.tag
self.segmentedControl.selectedSegmentIndex=index
}
@ IBAction func resetPressed(_:AnyObject){
self.segmentedControl.selectedSegmentIndex=-1
}
}
InterfaceBuilder has four UISegmentedControl (with three segments) and four UIButton (three of which have tag values of 0,1,2 and one for reset) connected to each @IBOutlet
, @IBAction
.With this much code, we have verified that UISegmentedControl can be operated by simply pressing the button without directly operating it.
If you believe that this should succeed, you may easily notice a mistake that you have not noticed before, so you can review it so that you can solve it yourself. If you are not sure, please delete the extra code until you can reproduce the error and add the full code to the question.(You should be able to edit your own questions.)
© 2024 OneMinuteCode. All rights reserved.