Can not get textbox or UIPickerView to interact within a UIView Container View










1














I have been following this tutorial online:
https://medium.com/@jannism/segmented-control-tutorial-for-beginner-in-swift-4-8588a63b8bfd



It uses a Segmented Control to toggle UIView (container views) based on the index selection in the Segmented control.



The switching of the containers works as described in the tutorial, but the key portion where I wish to add either textboxes or a UIPicker in the container. The elements are displayed in the container view but I can NOT interact with them!?



Does anyone know how I can get this to work?



The main view controller which holds the three UIViews (aka containers)



class ViewController: UIViewController, TwicketSegmentedControlDelegate 

// OUTLETS AND VARIABLES
@IBOutlet weak var showHome: UIView!
@IBOutlet weak var showProfile: UIView!
@IBOutlet weak var showSettings: UIView!


// BACKGROUND OF THE TOP SLIDER
var segmentControlView: UIView =
var uiView = UIView()
uiView.backgroundColor = UIColor.white
return uiView
()


// DISPLAY SLIDER
var contentView:UIView =
var uiView = UIView()
return uiView
()


// DESIGN OF THE SEGMENT
var twicketSegmentControl:TwicketSegmentedControl =

var twicketSegmentControl : TwicketSegmentedControl = TwicketSegmentedControl(frame:CGRect.zero)

// SETTING THE TITLES
let titles = ["Home", "Profile", "Settings"]
twicketSegmentControl.setSegmentItems(titles)

// SETTING THE TEXT COLOR OF THE CHOSEN SEGMENT TO WHITE
twicketSegmentControl.highlightTextColor = UIColor.white

// SETTING THE TEXT COLOR OF THE OTHER SEGMENTS TO A DARK GRAY
twicketSegmentControl.defaultTextColor = UIColor.init(red: 171/255.0, green: 183/255.0, blue: 183/255.0, alpha: 1.0)

// SETTING THE BACKGROUND COLOR OF THE CHOSEN SEGMENT TO BLUE
twicketSegmentControl.sliderBackgroundColor = UIColor.init(red: 31/255.0, green: 58/255.0, blue: 147/255.0, alpha: 1.0)

// SETTING THE BACKGROUND COLOR OF THE OTHER SEGMENTS TO A VERY LIGHT GRAY
twicketSegmentControl.segmentsBackgroundColor = UIColor.init(red: 238/255.0, green: 238/255.0, blue: 238/255.0, alpha: 1.0)

// SHOWS SEGMENTS
return twicketSegmentControl
()


override func viewDidLoad()
super.viewDidLoad()
// LOADING THE HOME SWITCH AS THE DEFAULT VIEW
didSelect(0)

super.viewDidLoad()
configureViewHierarchy()



// VIEWS
func configureViewHierarchy()
view.addSubview(segmentControlView)
segmentControlView.snp.makeConstraints (make) in
make.top.left.right.equalTo(view)


segmentControlView.addSubview(twicketSegmentControl)
twicketSegmentControl.delegate = self;
twicketSegmentControl.snp.makeConstraints (make) in

// PUTS THE SEGMENT CONTROL 30px (= THE HEIGHT OF THE CONTROL) OVER THE VIEW
make.top.equalTo(showHome).offset(-30)

// DEFINE THE BORDERS TO THE SIDES
make.left.equalTo(segmentControlView).offset(16)
make.right.equalTo(segmentControlView).offset(-16)

make.bottom.equalTo(segmentControlView).offset(-10)

// DEFINE THE HEIGHT
make.height.equalTo(30)


view.addSubview(contentView)
contentView.snp.makeConstraints (make) in
make.left.right.equalTo(view)
make.bottom.equalTo(view)
make.top.equalTo(segmentControlView.snp.bottom)





override func didReceiveMemoryWarning()
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.



// CHOSING VIEW BASED ON SEGMENT CHOSEN
func didSelect(_ segmentIndex: Int)

switch segmentIndex

case 0:
// SHOWING THE HOME VIEW
showProfile.alpha = 0
showSettings.alpha = 0
showHome.alpha = 1

case 1:
// SHOWING THE PROFILE VIEW
showHome.alpha = 0
showSettings.alpha = 0
showProfile.alpha = 1

case 2:
// SHOWING THE SETTINGS VIEW
showHome.alpha = 0
showProfile.alpha = 0
showSettings.alpha = 1

default:
break;







The Settings ViewController is a such:



class SettingViewController: UIViewController 

@IBOutlet weak var textField: UITextField!

override func viewDidLoad()
super.viewDidLoad()
// Do any additional setup after loading the view.






As I said, I have it really simple so that I can debug the issue prior to including more complexity.



Attached is the storyboard
enter image description here










share|improve this question























  • Can you add your code please?
    – Robert Dresler
    Nov 11 at 17:18










  • @RobertDresler i have added my code
    – Famic Tech
    Nov 11 at 17:36










  • If you say " I can NOT interact with them" do you mean you can't for example tap to button inside view?
    – Robert Dresler
    Nov 11 at 17:46










  • @RobertDresler that is correct. The UIView loads based on the Segmented index as desired but if I click on any element, nothing happens including displaying the input keyboard!?
    – Famic Tech
    Nov 11 at 17:49










  • Make sure you have for showHome, showProfile and showSettings enabled interactions
    – Robert Dresler
    Nov 11 at 18:02















1














I have been following this tutorial online:
https://medium.com/@jannism/segmented-control-tutorial-for-beginner-in-swift-4-8588a63b8bfd



It uses a Segmented Control to toggle UIView (container views) based on the index selection in the Segmented control.



The switching of the containers works as described in the tutorial, but the key portion where I wish to add either textboxes or a UIPicker in the container. The elements are displayed in the container view but I can NOT interact with them!?



Does anyone know how I can get this to work?



The main view controller which holds the three UIViews (aka containers)



class ViewController: UIViewController, TwicketSegmentedControlDelegate 

// OUTLETS AND VARIABLES
@IBOutlet weak var showHome: UIView!
@IBOutlet weak var showProfile: UIView!
@IBOutlet weak var showSettings: UIView!


// BACKGROUND OF THE TOP SLIDER
var segmentControlView: UIView =
var uiView = UIView()
uiView.backgroundColor = UIColor.white
return uiView
()


// DISPLAY SLIDER
var contentView:UIView =
var uiView = UIView()
return uiView
()


// DESIGN OF THE SEGMENT
var twicketSegmentControl:TwicketSegmentedControl =

var twicketSegmentControl : TwicketSegmentedControl = TwicketSegmentedControl(frame:CGRect.zero)

// SETTING THE TITLES
let titles = ["Home", "Profile", "Settings"]
twicketSegmentControl.setSegmentItems(titles)

// SETTING THE TEXT COLOR OF THE CHOSEN SEGMENT TO WHITE
twicketSegmentControl.highlightTextColor = UIColor.white

// SETTING THE TEXT COLOR OF THE OTHER SEGMENTS TO A DARK GRAY
twicketSegmentControl.defaultTextColor = UIColor.init(red: 171/255.0, green: 183/255.0, blue: 183/255.0, alpha: 1.0)

// SETTING THE BACKGROUND COLOR OF THE CHOSEN SEGMENT TO BLUE
twicketSegmentControl.sliderBackgroundColor = UIColor.init(red: 31/255.0, green: 58/255.0, blue: 147/255.0, alpha: 1.0)

// SETTING THE BACKGROUND COLOR OF THE OTHER SEGMENTS TO A VERY LIGHT GRAY
twicketSegmentControl.segmentsBackgroundColor = UIColor.init(red: 238/255.0, green: 238/255.0, blue: 238/255.0, alpha: 1.0)

// SHOWS SEGMENTS
return twicketSegmentControl
()


override func viewDidLoad()
super.viewDidLoad()
// LOADING THE HOME SWITCH AS THE DEFAULT VIEW
didSelect(0)

super.viewDidLoad()
configureViewHierarchy()



// VIEWS
func configureViewHierarchy()
view.addSubview(segmentControlView)
segmentControlView.snp.makeConstraints (make) in
make.top.left.right.equalTo(view)


segmentControlView.addSubview(twicketSegmentControl)
twicketSegmentControl.delegate = self;
twicketSegmentControl.snp.makeConstraints (make) in

// PUTS THE SEGMENT CONTROL 30px (= THE HEIGHT OF THE CONTROL) OVER THE VIEW
make.top.equalTo(showHome).offset(-30)

// DEFINE THE BORDERS TO THE SIDES
make.left.equalTo(segmentControlView).offset(16)
make.right.equalTo(segmentControlView).offset(-16)

make.bottom.equalTo(segmentControlView).offset(-10)

// DEFINE THE HEIGHT
make.height.equalTo(30)


view.addSubview(contentView)
contentView.snp.makeConstraints (make) in
make.left.right.equalTo(view)
make.bottom.equalTo(view)
make.top.equalTo(segmentControlView.snp.bottom)





override func didReceiveMemoryWarning()
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.



// CHOSING VIEW BASED ON SEGMENT CHOSEN
func didSelect(_ segmentIndex: Int)

switch segmentIndex

case 0:
// SHOWING THE HOME VIEW
showProfile.alpha = 0
showSettings.alpha = 0
showHome.alpha = 1

case 1:
// SHOWING THE PROFILE VIEW
showHome.alpha = 0
showSettings.alpha = 0
showProfile.alpha = 1

case 2:
// SHOWING THE SETTINGS VIEW
showHome.alpha = 0
showProfile.alpha = 0
showSettings.alpha = 1

default:
break;







The Settings ViewController is a such:



class SettingViewController: UIViewController 

@IBOutlet weak var textField: UITextField!

override func viewDidLoad()
super.viewDidLoad()
// Do any additional setup after loading the view.






As I said, I have it really simple so that I can debug the issue prior to including more complexity.



Attached is the storyboard
enter image description here










share|improve this question























  • Can you add your code please?
    – Robert Dresler
    Nov 11 at 17:18










  • @RobertDresler i have added my code
    – Famic Tech
    Nov 11 at 17:36










  • If you say " I can NOT interact with them" do you mean you can't for example tap to button inside view?
    – Robert Dresler
    Nov 11 at 17:46










  • @RobertDresler that is correct. The UIView loads based on the Segmented index as desired but if I click on any element, nothing happens including displaying the input keyboard!?
    – Famic Tech
    Nov 11 at 17:49










  • Make sure you have for showHome, showProfile and showSettings enabled interactions
    – Robert Dresler
    Nov 11 at 18:02













1












1








1







I have been following this tutorial online:
https://medium.com/@jannism/segmented-control-tutorial-for-beginner-in-swift-4-8588a63b8bfd



It uses a Segmented Control to toggle UIView (container views) based on the index selection in the Segmented control.



The switching of the containers works as described in the tutorial, but the key portion where I wish to add either textboxes or a UIPicker in the container. The elements are displayed in the container view but I can NOT interact with them!?



Does anyone know how I can get this to work?



The main view controller which holds the three UIViews (aka containers)



class ViewController: UIViewController, TwicketSegmentedControlDelegate 

// OUTLETS AND VARIABLES
@IBOutlet weak var showHome: UIView!
@IBOutlet weak var showProfile: UIView!
@IBOutlet weak var showSettings: UIView!


// BACKGROUND OF THE TOP SLIDER
var segmentControlView: UIView =
var uiView = UIView()
uiView.backgroundColor = UIColor.white
return uiView
()


// DISPLAY SLIDER
var contentView:UIView =
var uiView = UIView()
return uiView
()


// DESIGN OF THE SEGMENT
var twicketSegmentControl:TwicketSegmentedControl =

var twicketSegmentControl : TwicketSegmentedControl = TwicketSegmentedControl(frame:CGRect.zero)

// SETTING THE TITLES
let titles = ["Home", "Profile", "Settings"]
twicketSegmentControl.setSegmentItems(titles)

// SETTING THE TEXT COLOR OF THE CHOSEN SEGMENT TO WHITE
twicketSegmentControl.highlightTextColor = UIColor.white

// SETTING THE TEXT COLOR OF THE OTHER SEGMENTS TO A DARK GRAY
twicketSegmentControl.defaultTextColor = UIColor.init(red: 171/255.0, green: 183/255.0, blue: 183/255.0, alpha: 1.0)

// SETTING THE BACKGROUND COLOR OF THE CHOSEN SEGMENT TO BLUE
twicketSegmentControl.sliderBackgroundColor = UIColor.init(red: 31/255.0, green: 58/255.0, blue: 147/255.0, alpha: 1.0)

// SETTING THE BACKGROUND COLOR OF THE OTHER SEGMENTS TO A VERY LIGHT GRAY
twicketSegmentControl.segmentsBackgroundColor = UIColor.init(red: 238/255.0, green: 238/255.0, blue: 238/255.0, alpha: 1.0)

// SHOWS SEGMENTS
return twicketSegmentControl
()


override func viewDidLoad()
super.viewDidLoad()
// LOADING THE HOME SWITCH AS THE DEFAULT VIEW
didSelect(0)

super.viewDidLoad()
configureViewHierarchy()



// VIEWS
func configureViewHierarchy()
view.addSubview(segmentControlView)
segmentControlView.snp.makeConstraints (make) in
make.top.left.right.equalTo(view)


segmentControlView.addSubview(twicketSegmentControl)
twicketSegmentControl.delegate = self;
twicketSegmentControl.snp.makeConstraints (make) in

// PUTS THE SEGMENT CONTROL 30px (= THE HEIGHT OF THE CONTROL) OVER THE VIEW
make.top.equalTo(showHome).offset(-30)

// DEFINE THE BORDERS TO THE SIDES
make.left.equalTo(segmentControlView).offset(16)
make.right.equalTo(segmentControlView).offset(-16)

make.bottom.equalTo(segmentControlView).offset(-10)

// DEFINE THE HEIGHT
make.height.equalTo(30)


view.addSubview(contentView)
contentView.snp.makeConstraints (make) in
make.left.right.equalTo(view)
make.bottom.equalTo(view)
make.top.equalTo(segmentControlView.snp.bottom)





override func didReceiveMemoryWarning()
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.



// CHOSING VIEW BASED ON SEGMENT CHOSEN
func didSelect(_ segmentIndex: Int)

switch segmentIndex

case 0:
// SHOWING THE HOME VIEW
showProfile.alpha = 0
showSettings.alpha = 0
showHome.alpha = 1

case 1:
// SHOWING THE PROFILE VIEW
showHome.alpha = 0
showSettings.alpha = 0
showProfile.alpha = 1

case 2:
// SHOWING THE SETTINGS VIEW
showHome.alpha = 0
showProfile.alpha = 0
showSettings.alpha = 1

default:
break;







The Settings ViewController is a such:



class SettingViewController: UIViewController 

@IBOutlet weak var textField: UITextField!

override func viewDidLoad()
super.viewDidLoad()
// Do any additional setup after loading the view.






As I said, I have it really simple so that I can debug the issue prior to including more complexity.



Attached is the storyboard
enter image description here










share|improve this question















I have been following this tutorial online:
https://medium.com/@jannism/segmented-control-tutorial-for-beginner-in-swift-4-8588a63b8bfd



It uses a Segmented Control to toggle UIView (container views) based on the index selection in the Segmented control.



The switching of the containers works as described in the tutorial, but the key portion where I wish to add either textboxes or a UIPicker in the container. The elements are displayed in the container view but I can NOT interact with them!?



Does anyone know how I can get this to work?



The main view controller which holds the three UIViews (aka containers)



class ViewController: UIViewController, TwicketSegmentedControlDelegate 

// OUTLETS AND VARIABLES
@IBOutlet weak var showHome: UIView!
@IBOutlet weak var showProfile: UIView!
@IBOutlet weak var showSettings: UIView!


// BACKGROUND OF THE TOP SLIDER
var segmentControlView: UIView =
var uiView = UIView()
uiView.backgroundColor = UIColor.white
return uiView
()


// DISPLAY SLIDER
var contentView:UIView =
var uiView = UIView()
return uiView
()


// DESIGN OF THE SEGMENT
var twicketSegmentControl:TwicketSegmentedControl =

var twicketSegmentControl : TwicketSegmentedControl = TwicketSegmentedControl(frame:CGRect.zero)

// SETTING THE TITLES
let titles = ["Home", "Profile", "Settings"]
twicketSegmentControl.setSegmentItems(titles)

// SETTING THE TEXT COLOR OF THE CHOSEN SEGMENT TO WHITE
twicketSegmentControl.highlightTextColor = UIColor.white

// SETTING THE TEXT COLOR OF THE OTHER SEGMENTS TO A DARK GRAY
twicketSegmentControl.defaultTextColor = UIColor.init(red: 171/255.0, green: 183/255.0, blue: 183/255.0, alpha: 1.0)

// SETTING THE BACKGROUND COLOR OF THE CHOSEN SEGMENT TO BLUE
twicketSegmentControl.sliderBackgroundColor = UIColor.init(red: 31/255.0, green: 58/255.0, blue: 147/255.0, alpha: 1.0)

// SETTING THE BACKGROUND COLOR OF THE OTHER SEGMENTS TO A VERY LIGHT GRAY
twicketSegmentControl.segmentsBackgroundColor = UIColor.init(red: 238/255.0, green: 238/255.0, blue: 238/255.0, alpha: 1.0)

// SHOWS SEGMENTS
return twicketSegmentControl
()


override func viewDidLoad()
super.viewDidLoad()
// LOADING THE HOME SWITCH AS THE DEFAULT VIEW
didSelect(0)

super.viewDidLoad()
configureViewHierarchy()



// VIEWS
func configureViewHierarchy()
view.addSubview(segmentControlView)
segmentControlView.snp.makeConstraints (make) in
make.top.left.right.equalTo(view)


segmentControlView.addSubview(twicketSegmentControl)
twicketSegmentControl.delegate = self;
twicketSegmentControl.snp.makeConstraints (make) in

// PUTS THE SEGMENT CONTROL 30px (= THE HEIGHT OF THE CONTROL) OVER THE VIEW
make.top.equalTo(showHome).offset(-30)

// DEFINE THE BORDERS TO THE SIDES
make.left.equalTo(segmentControlView).offset(16)
make.right.equalTo(segmentControlView).offset(-16)

make.bottom.equalTo(segmentControlView).offset(-10)

// DEFINE THE HEIGHT
make.height.equalTo(30)


view.addSubview(contentView)
contentView.snp.makeConstraints (make) in
make.left.right.equalTo(view)
make.bottom.equalTo(view)
make.top.equalTo(segmentControlView.snp.bottom)





override func didReceiveMemoryWarning()
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.



// CHOSING VIEW BASED ON SEGMENT CHOSEN
func didSelect(_ segmentIndex: Int)

switch segmentIndex

case 0:
// SHOWING THE HOME VIEW
showProfile.alpha = 0
showSettings.alpha = 0
showHome.alpha = 1

case 1:
// SHOWING THE PROFILE VIEW
showHome.alpha = 0
showSettings.alpha = 0
showProfile.alpha = 1

case 2:
// SHOWING THE SETTINGS VIEW
showHome.alpha = 0
showProfile.alpha = 0
showSettings.alpha = 1

default:
break;







The Settings ViewController is a such:



class SettingViewController: UIViewController 

@IBOutlet weak var textField: UITextField!

override func viewDidLoad()
super.viewDidLoad()
// Do any additional setup after loading the view.






As I said, I have it really simple so that I can debug the issue prior to including more complexity.



Attached is the storyboard
enter image description here







swift uisegmentedcontrol uicontainerview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 19:41

























asked Nov 11 at 17:16









Famic Tech

179216




179216











  • Can you add your code please?
    – Robert Dresler
    Nov 11 at 17:18










  • @RobertDresler i have added my code
    – Famic Tech
    Nov 11 at 17:36










  • If you say " I can NOT interact with them" do you mean you can't for example tap to button inside view?
    – Robert Dresler
    Nov 11 at 17:46










  • @RobertDresler that is correct. The UIView loads based on the Segmented index as desired but if I click on any element, nothing happens including displaying the input keyboard!?
    – Famic Tech
    Nov 11 at 17:49










  • Make sure you have for showHome, showProfile and showSettings enabled interactions
    – Robert Dresler
    Nov 11 at 18:02
















  • Can you add your code please?
    – Robert Dresler
    Nov 11 at 17:18










  • @RobertDresler i have added my code
    – Famic Tech
    Nov 11 at 17:36










  • If you say " I can NOT interact with them" do you mean you can't for example tap to button inside view?
    – Robert Dresler
    Nov 11 at 17:46










  • @RobertDresler that is correct. The UIView loads based on the Segmented index as desired but if I click on any element, nothing happens including displaying the input keyboard!?
    – Famic Tech
    Nov 11 at 17:49










  • Make sure you have for showHome, showProfile and showSettings enabled interactions
    – Robert Dresler
    Nov 11 at 18:02















Can you add your code please?
– Robert Dresler
Nov 11 at 17:18




Can you add your code please?
– Robert Dresler
Nov 11 at 17:18












@RobertDresler i have added my code
– Famic Tech
Nov 11 at 17:36




@RobertDresler i have added my code
– Famic Tech
Nov 11 at 17:36












If you say " I can NOT interact with them" do you mean you can't for example tap to button inside view?
– Robert Dresler
Nov 11 at 17:46




If you say " I can NOT interact with them" do you mean you can't for example tap to button inside view?
– Robert Dresler
Nov 11 at 17:46












@RobertDresler that is correct. The UIView loads based on the Segmented index as desired but if I click on any element, nothing happens including displaying the input keyboard!?
– Famic Tech
Nov 11 at 17:49




@RobertDresler that is correct. The UIView loads based on the Segmented index as desired but if I click on any element, nothing happens including displaying the input keyboard!?
– Famic Tech
Nov 11 at 17:49












Make sure you have for showHome, showProfile and showSettings enabled interactions
– Robert Dresler
Nov 11 at 18:02




Make sure you have for showHome, showProfile and showSettings enabled interactions
– Robert Dresler
Nov 11 at 18:02












1 Answer
1






active

oldest

votes


















0














You are adding a UIView named contentView covering your container views.



This contentView doesn't appear to do anything, other than prevent interaction with the views it is covering.



If you comment-out (or delete) these lines in your configureViewHierarchy() func:



// view.addSubview(contentView)
// contentView.snp.makeConstraints (make) in
// make.left.right.equalTo(view)
// make.bottom.equalTo(view)
// make.top.equalTo(segmentControlView.snp.bottom)
//


You should be able to interact with elements in your container views.



Although, your code is also setting .alpha values on your container views... I'd recommend using .isHidden instead:



func didSelect(_ segmentIndex: Int) 

showHome.isHidden = segmentIndex != 0
showProfile.isHidden = segmentIndex != 1
showSettings.isHidden = segmentIndex != 2

// if you need to run other code based on the selected segment
switch segmentIndex

case 0:
// SHOWING THE HOME VIEW
// do other stuff here...

case 1:
// SHOWING THE PROFILE VIEW
// do other stuff here...

case 2:
// SHOWING THE SETTINGS VIEW
// do other stuff here...

default:
break;








share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251202%2fcan-not-get-textbox-or-uipickerview-to-interact-within-a-uiview-container-view%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You are adding a UIView named contentView covering your container views.



    This contentView doesn't appear to do anything, other than prevent interaction with the views it is covering.



    If you comment-out (or delete) these lines in your configureViewHierarchy() func:



    // view.addSubview(contentView)
    // contentView.snp.makeConstraints (make) in
    // make.left.right.equalTo(view)
    // make.bottom.equalTo(view)
    // make.top.equalTo(segmentControlView.snp.bottom)
    //


    You should be able to interact with elements in your container views.



    Although, your code is also setting .alpha values on your container views... I'd recommend using .isHidden instead:



    func didSelect(_ segmentIndex: Int) 

    showHome.isHidden = segmentIndex != 0
    showProfile.isHidden = segmentIndex != 1
    showSettings.isHidden = segmentIndex != 2

    // if you need to run other code based on the selected segment
    switch segmentIndex

    case 0:
    // SHOWING THE HOME VIEW
    // do other stuff here...

    case 1:
    // SHOWING THE PROFILE VIEW
    // do other stuff here...

    case 2:
    // SHOWING THE SETTINGS VIEW
    // do other stuff here...

    default:
    break;








    share|improve this answer

























      0














      You are adding a UIView named contentView covering your container views.



      This contentView doesn't appear to do anything, other than prevent interaction with the views it is covering.



      If you comment-out (or delete) these lines in your configureViewHierarchy() func:



      // view.addSubview(contentView)
      // contentView.snp.makeConstraints (make) in
      // make.left.right.equalTo(view)
      // make.bottom.equalTo(view)
      // make.top.equalTo(segmentControlView.snp.bottom)
      //


      You should be able to interact with elements in your container views.



      Although, your code is also setting .alpha values on your container views... I'd recommend using .isHidden instead:



      func didSelect(_ segmentIndex: Int) 

      showHome.isHidden = segmentIndex != 0
      showProfile.isHidden = segmentIndex != 1
      showSettings.isHidden = segmentIndex != 2

      // if you need to run other code based on the selected segment
      switch segmentIndex

      case 0:
      // SHOWING THE HOME VIEW
      // do other stuff here...

      case 1:
      // SHOWING THE PROFILE VIEW
      // do other stuff here...

      case 2:
      // SHOWING THE SETTINGS VIEW
      // do other stuff here...

      default:
      break;








      share|improve this answer























        0












        0








        0






        You are adding a UIView named contentView covering your container views.



        This contentView doesn't appear to do anything, other than prevent interaction with the views it is covering.



        If you comment-out (or delete) these lines in your configureViewHierarchy() func:



        // view.addSubview(contentView)
        // contentView.snp.makeConstraints (make) in
        // make.left.right.equalTo(view)
        // make.bottom.equalTo(view)
        // make.top.equalTo(segmentControlView.snp.bottom)
        //


        You should be able to interact with elements in your container views.



        Although, your code is also setting .alpha values on your container views... I'd recommend using .isHidden instead:



        func didSelect(_ segmentIndex: Int) 

        showHome.isHidden = segmentIndex != 0
        showProfile.isHidden = segmentIndex != 1
        showSettings.isHidden = segmentIndex != 2

        // if you need to run other code based on the selected segment
        switch segmentIndex

        case 0:
        // SHOWING THE HOME VIEW
        // do other stuff here...

        case 1:
        // SHOWING THE PROFILE VIEW
        // do other stuff here...

        case 2:
        // SHOWING THE SETTINGS VIEW
        // do other stuff here...

        default:
        break;








        share|improve this answer












        You are adding a UIView named contentView covering your container views.



        This contentView doesn't appear to do anything, other than prevent interaction with the views it is covering.



        If you comment-out (or delete) these lines in your configureViewHierarchy() func:



        // view.addSubview(contentView)
        // contentView.snp.makeConstraints (make) in
        // make.left.right.equalTo(view)
        // make.bottom.equalTo(view)
        // make.top.equalTo(segmentControlView.snp.bottom)
        //


        You should be able to interact with elements in your container views.



        Although, your code is also setting .alpha values on your container views... I'd recommend using .isHidden instead:



        func didSelect(_ segmentIndex: Int) 

        showHome.isHidden = segmentIndex != 0
        showProfile.isHidden = segmentIndex != 1
        showSettings.isHidden = segmentIndex != 2

        // if you need to run other code based on the selected segment
        switch segmentIndex

        case 0:
        // SHOWING THE HOME VIEW
        // do other stuff here...

        case 1:
        // SHOWING THE PROFILE VIEW
        // do other stuff here...

        case 2:
        // SHOWING THE SETTINGS VIEW
        // do other stuff here...

        default:
        break;









        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 14:18









        DonMag

        15.8k2927




        15.8k2927



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251202%2fcan-not-get-textbox-or-uipickerview-to-interact-within-a-uiview-container-view%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo