0
votes

In my ios applicaiton, the segment control is setting itself according to the storyboard even when some coordinates have been specified inside the viewDidLoad() function.

override func viewDidLoad() { super.viewDidLoad()

    changeBackground()
    changeBackground2()

    trainSearchView.layer.cornerRadius = 12
    passengerCheckinView.layer.cornerRadius = 12
    trainsStatusVIew.layer.cornerRadius = 12


    trainFrom.hidden = true
    trainTo.hidden = true
    trainNumber.hidden = true
    trainName.hidden = false
    activityIndicator.hidden = true

    daySelector.addE

    dispatch_async(dispatch_get_main_queue()){

        self.radioTrainNumber.frame = CGRectMake(self.betweenStation.frame.origin.x, self.betweenStation.frame.origin.y + 40, self.radioTrainNumber.frame.size.width, self.radioTrainNumber.frame.size.height)
        self.radioTrainName.frame = CGRectMake(self.radioTrainNumber.frame.origin.x, self.radioTrainNumber.frame.origin.y + 40, self.radioTrainName.frame.size.width, self.radioTrainName.frame.size.height)
        self.trainName.frame = CGRectMake(self.trainFrom.frame.origin.x, self.radioTrainName.frame.origin.y + 40, self.trainName.frame.size.width, self.trainName.frame.size.height)
        self.daySelector.frame = CGRectMake(self.daySelector.frame.origin.x, self.trainName.frame.origin.y + 55, self.daySelector.frame.size.width, self.daySelector.frame.size.height)
        self.searchButton.frame = CGRectMake(self.searchButton.frame.origin.x, self.daySelector.frame.origin.y + 55, self.searchButton.frame.size.width, self.searchButton.frame.size.height)

        let borderTrainSearch = UIView()
        borderTrainSearch.frame = CGRect(x: self.trainSearchLabel.frame.origin.x + self.trainSearchLabel.frame.size.width, y: self.trainSearchLabel.frame.origin.y, width: 5,height: self.trainSearchView.frame.size.height )
        borderTrainSearch.backgroundColor = UIColor.blackColor()

    }
}

@IBAction func dayChanged(sender: UISegmentedControl) {

    if flagForRadioPosition {

        daySelector.frame = CGRectMake(daySelector.frame.origin.x, radioTrainName.frame.origin.y + 55, daySelector.frame.size.width, daySelector.frame.size.height)

    }
    else {

        self.daySelector.frame = CGRectMake(self.daySelector.frame.origin.x, self.trainName.frame.origin.y + 60, self.daySelector.frame.size.width, self.daySelector.frame.size.height)
    }

}
1
What do you want to say?Mr. Bond
I have a segment control and three button in my UI. When i click any of the 3 buttons, then the position of Segment should change. That is happening, but when i click on the SegmentControl, it places itself according to the position specified in the storyboardSachindeep Singh
can you show me your code?Mr. Bond
what do you specifically want to see ? so that I can post that partSachindeep Singh
viewdidload, and segment control codeMr. Bond

1 Answers

0
votes

The Reason for the above is some sort of linkage to the storyboard. However I have avoided this by programmatically creating the segment control and it is working just fine