Segmented control, multiple views

64 views
Skip to first unread message

ecarter202

unread,
Dec 7, 2014, 12:27:42 PM12/7/14
to swift-l...@googlegroups.com
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!

GoDoStartupNow

unread,
Jan 2, 2015, 7:11:35 AM1/2/15
to swift-l...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages