Segmented control, multiple views

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Segmented control, multiple views

ecarter202
Problem: segmented view is not displaying the second view control I have setup. The constraints are the same as the first, which works just as it should (hides/displays on selected/deselect).
I have tried a switch in place of the ifs, as well, with no success.









import UIKit




class FirstViewController: UIViewController {


   


    @IBOutlet weak var segmentedControl1: UISegmentedControl!




    @IBOutlet weak var viewF1: UIView!


    @IBOutlet weak var viewF2: UIView!


   


    override func viewDidLoad() {


        super.viewDidLoad()


        // Do any additional setup after loading the view, typically from a nib.
       viewF2
.hidden =true; // Makes the 2nd view hidden onload.


    }




    override func didReceiveMemoryWarning() {


        super.didReceiveMemoryWarning()


        // Dispose of any resources that can be recreated.


    }




    @IBAction func viewChanger1(sender: UISegmentedControl) {


       


        if segmentedControl1.selectedSegmentIndex == 0


        {


            viewF2.hidden = true;


            viewF1.hidden = false;


        }


        if segmentedControl1.selectedSegmentIndex != 0


        {


            viewF1.hidden = true;


            viewF2.hidden = false;


        }


    }


   


}



Thank you!

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/b9cc85c2-68a6-40dc-a3be-c6caf4bc1868%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Segmented control, multiple views

GoDoStartupNow
Your code looks fine to me. Try to use auto layout and stick the view items to the upper-left corner of the screen to ensure on-screen display. Let me know if you want help via my Skype ID GoDoStartupNow

On Sunday, December 7, 2014 12:27:42 PM UTC-5, ecarter202 wrote:
Problem: segmented view is not displaying the second view control I have setup. The constraints are the same as the first, which works just as it should (hides/displays on selected/deselect).
I have tried a switch in place of the ifs, as well, with no success.









import UIKit




class FirstViewController: UIViewController {


   


    @IBOutlet weak var segmentedControl1: UISegmentedControl!




    @IBOutlet weak var viewF1: UIView!


    @IBOutlet weak var viewF2: UIView!


   


    override func viewDidLoad() {


        super.viewDidLoad()


        // Do any additional setup after loading the view, typically from a nib.
       viewF2
.hidden =true; // Makes the 2nd view hidden onload.


    }




    override func didReceiveMemoryWarning() {


        super.didReceiveMemoryWarning()


        // Dispose of any resources that can be recreated.


    }




    @IBAction func viewChanger1(sender: UISegmentedControl) {


       


        if segmentedControl1.selectedSegmentIndex == 0


        {


            viewF2.hidden = true;


            viewF1.hidden = false;


        }


        if segmentedControl1.selectedSegmentIndex != 0


        {


            viewF1.hidden = true;


            viewF2.hidden = false;


        }


    }


   


}



Thank you!

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/490a15bc-1593-4715-9708-19fd47722d88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.