Changing variables of a custom UIView in another custom ViewController












0















I know it may be the basic question but I am new to Swift.
Also, I have tried various solutions on SO but could not resolve the issue.
So if anyone can help me with my problem.



I have a custom UIVIEW class as follows:



class SearchTextFieldView: UIView, UITextFieldDelegate{
public var searchText = UITextField()


override init(frame: CGRect) {
super.init(frame: frame)
initializeUI()
}


required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initializeUI()
}



func initializeUI() {
searchText.placeholder = "Enter model no"
searchText.backgroundColor = UIColor.white
searchText.textColor = UIColor.darkGray
searchText.layer.cornerRadius = 5.0
searchText.delegate=self
self.addSubview(searchText)

}

override func layoutSubviews() {
searchText.frame = CGRect(x: 20.0, y: 5.0, width: self.frame.size.width - 40,height : self.frame.size.height - 10)
}
}


Now I want to set text to SearchText textfield from another class which is as follows:



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

func setupUI() {

let searchTextFieldView = SearchTextFieldView()
self.view.addSubview(searchTextFieldView) //adding view containing search box view at the top
**searchTextFieldView.searchText.text = "My Text"**
}


I am using Storyboard. Also, I can see the textfield with placeholder text.only problem is I can not set text to it.
Can anybody help. Whats wrong in my code.










share|improve this question

























  • Make sure that "initializeUI" method called on your SearchTextFieldView. Because you just do normal init(SearchTextFieldView()) instead of "init(frame: CGRect)".

    – Natarajan
    Nov 19 '18 at 7:45
















0















I know it may be the basic question but I am new to Swift.
Also, I have tried various solutions on SO but could not resolve the issue.
So if anyone can help me with my problem.



I have a custom UIVIEW class as follows:



class SearchTextFieldView: UIView, UITextFieldDelegate{
public var searchText = UITextField()


override init(frame: CGRect) {
super.init(frame: frame)
initializeUI()
}


required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initializeUI()
}



func initializeUI() {
searchText.placeholder = "Enter model no"
searchText.backgroundColor = UIColor.white
searchText.textColor = UIColor.darkGray
searchText.layer.cornerRadius = 5.0
searchText.delegate=self
self.addSubview(searchText)

}

override func layoutSubviews() {
searchText.frame = CGRect(x: 20.0, y: 5.0, width: self.frame.size.width - 40,height : self.frame.size.height - 10)
}
}


Now I want to set text to SearchText textfield from another class which is as follows:



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

func setupUI() {

let searchTextFieldView = SearchTextFieldView()
self.view.addSubview(searchTextFieldView) //adding view containing search box view at the top
**searchTextFieldView.searchText.text = "My Text"**
}


I am using Storyboard. Also, I can see the textfield with placeholder text.only problem is I can not set text to it.
Can anybody help. Whats wrong in my code.










share|improve this question

























  • Make sure that "initializeUI" method called on your SearchTextFieldView. Because you just do normal init(SearchTextFieldView()) instead of "init(frame: CGRect)".

    – Natarajan
    Nov 19 '18 at 7:45














0












0








0








I know it may be the basic question but I am new to Swift.
Also, I have tried various solutions on SO but could not resolve the issue.
So if anyone can help me with my problem.



I have a custom UIVIEW class as follows:



class SearchTextFieldView: UIView, UITextFieldDelegate{
public var searchText = UITextField()


override init(frame: CGRect) {
super.init(frame: frame)
initializeUI()
}


required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initializeUI()
}



func initializeUI() {
searchText.placeholder = "Enter model no"
searchText.backgroundColor = UIColor.white
searchText.textColor = UIColor.darkGray
searchText.layer.cornerRadius = 5.0
searchText.delegate=self
self.addSubview(searchText)

}

override func layoutSubviews() {
searchText.frame = CGRect(x: 20.0, y: 5.0, width: self.frame.size.width - 40,height : self.frame.size.height - 10)
}
}


Now I want to set text to SearchText textfield from another class which is as follows:



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

func setupUI() {

let searchTextFieldView = SearchTextFieldView()
self.view.addSubview(searchTextFieldView) //adding view containing search box view at the top
**searchTextFieldView.searchText.text = "My Text"**
}


I am using Storyboard. Also, I can see the textfield with placeholder text.only problem is I can not set text to it.
Can anybody help. Whats wrong in my code.










share|improve this question
















I know it may be the basic question but I am new to Swift.
Also, I have tried various solutions on SO but could not resolve the issue.
So if anyone can help me with my problem.



I have a custom UIVIEW class as follows:



class SearchTextFieldView: UIView, UITextFieldDelegate{
public var searchText = UITextField()


override init(frame: CGRect) {
super.init(frame: frame)
initializeUI()
}


required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initializeUI()
}



func initializeUI() {
searchText.placeholder = "Enter model no"
searchText.backgroundColor = UIColor.white
searchText.textColor = UIColor.darkGray
searchText.layer.cornerRadius = 5.0
searchText.delegate=self
self.addSubview(searchText)

}

override func layoutSubviews() {
searchText.frame = CGRect(x: 20.0, y: 5.0, width: self.frame.size.width - 40,height : self.frame.size.height - 10)
}
}


Now I want to set text to SearchText textfield from another class which is as follows:



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

func setupUI() {

let searchTextFieldView = SearchTextFieldView()
self.view.addSubview(searchTextFieldView) //adding view containing search box view at the top
**searchTextFieldView.searchText.text = "My Text"**
}


I am using Storyboard. Also, I can see the textfield with placeholder text.only problem is I can not set text to it.
Can anybody help. Whats wrong in my code.







ios swift uiview swift4






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 9:16







Nilesh

















asked Nov 19 '18 at 7:31









NileshNilesh

250312




250312













  • Make sure that "initializeUI" method called on your SearchTextFieldView. Because you just do normal init(SearchTextFieldView()) instead of "init(frame: CGRect)".

    – Natarajan
    Nov 19 '18 at 7:45



















  • Make sure that "initializeUI" method called on your SearchTextFieldView. Because you just do normal init(SearchTextFieldView()) instead of "init(frame: CGRect)".

    – Natarajan
    Nov 19 '18 at 7:45

















Make sure that "initializeUI" method called on your SearchTextFieldView. Because you just do normal init(SearchTextFieldView()) instead of "init(frame: CGRect)".

– Natarajan
Nov 19 '18 at 7:45





Make sure that "initializeUI" method called on your SearchTextFieldView. Because you just do normal init(SearchTextFieldView()) instead of "init(frame: CGRect)".

– Natarajan
Nov 19 '18 at 7:45












4 Answers
4






active

oldest

votes


















2














It is needed to call searchTextFieldView.setNeedsDisplay(), this will in turn call override func draw(_ rect: CGRect) in class SearchTextFieldView.



Add override func draw(_ rect: CGRect) {} in SearchTextFieldView, and try setting searchText.text = <someValue> in draw(). You can use a String property in SearchTextFieldView, to get <someValue> from the client (one who is using SearchTextFieldView) class.






share|improve this answer

































    1














    You are creating you view via SearchTextFieldView(), while you have 2 available initializers init(frame:) and init?(coder:).



    If you change



    let searchTextFieldView = SearchTextFieldView()


    with



    let searchTextFieldView = SearchTextFieldView(frame: CGRect(x: 50, y: 50, width: 100, height: 100))


    you will see the text.






    share|improve this answer
























    • This did not work. I forgot to mention in my question that I am using storyboard also I can see the textfield with placeholder text in it. Only problem is can not set text to it. Anything else you can suggest. Thanks.

      – Nilesh
      Nov 19 '18 at 8:49











    • So, are you trying to change text in view that was created programmatically, or that was added in storyboard. If it is the storyboard one, then you need to make an outlet and address it in your code.

      – Evgeniy
      Nov 19 '18 at 11:12



















    1














    You are not setting frame to the view. Also you are not loading the .xib in the view class. It should be like:-



    class SearchTextFieldView: UIView, UITextFieldDelegate{

    //MARK:- Initializer
    required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    initialize(withFrame: self.bounds)
    }

    override init(frame : CGRect) {
    super.init(frame: frame)
    initialize(withFrame: frame)
    }

    //MARK: - View Initializers
    func initialize(withFrame frame : CGRect) {

    Bundle.main.loadNibNamed("SearchTextFieldView", owner: self, options: nil)
    view.frame = frame
    view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
    self.addSubview(view)
    initializeUI()
    }
    }


    Now you can call the below code in view controller:-



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

    func setupUI() {
    let searchTextFieldView = SearchTextFieldView(frame: ?*self.view.bounds)
    self.view.addSubview(searchTextFieldView)
    //adding view containing search box view at the top
    searchTextFieldView.searchText.text = "My Text"
    }


    Don't forget to create an xib with name "SearchTextFieldView.xib" as you are loading that nib in your initialize function.



    Hope it helps :)






    share|improve this answer

































      1














      add frame for the searchTextFieldView inside setupUI() method. because the View got loaded on the view but its doesn't have a frame (x,y position, width and height). Change your UIViewController's colour to grey and u can see the your view loaded on the left corner (0,0). set frame size for the view that will solve this problem.






      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%2f53370102%2fchanging-variables-of-a-custom-uiview-in-another-custom-viewcontroller%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        2














        It is needed to call searchTextFieldView.setNeedsDisplay(), this will in turn call override func draw(_ rect: CGRect) in class SearchTextFieldView.



        Add override func draw(_ rect: CGRect) {} in SearchTextFieldView, and try setting searchText.text = <someValue> in draw(). You can use a String property in SearchTextFieldView, to get <someValue> from the client (one who is using SearchTextFieldView) class.






        share|improve this answer






























          2














          It is needed to call searchTextFieldView.setNeedsDisplay(), this will in turn call override func draw(_ rect: CGRect) in class SearchTextFieldView.



          Add override func draw(_ rect: CGRect) {} in SearchTextFieldView, and try setting searchText.text = <someValue> in draw(). You can use a String property in SearchTextFieldView, to get <someValue> from the client (one who is using SearchTextFieldView) class.






          share|improve this answer




























            2












            2








            2







            It is needed to call searchTextFieldView.setNeedsDisplay(), this will in turn call override func draw(_ rect: CGRect) in class SearchTextFieldView.



            Add override func draw(_ rect: CGRect) {} in SearchTextFieldView, and try setting searchText.text = <someValue> in draw(). You can use a String property in SearchTextFieldView, to get <someValue> from the client (one who is using SearchTextFieldView) class.






            share|improve this answer















            It is needed to call searchTextFieldView.setNeedsDisplay(), this will in turn call override func draw(_ rect: CGRect) in class SearchTextFieldView.



            Add override func draw(_ rect: CGRect) {} in SearchTextFieldView, and try setting searchText.text = <someValue> in draw(). You can use a String property in SearchTextFieldView, to get <someValue> from the client (one who is using SearchTextFieldView) class.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 19 '18 at 13:11

























            answered Nov 19 '18 at 7:42









            RizwanRizwan

            1,606419




            1,606419

























                1














                You are creating you view via SearchTextFieldView(), while you have 2 available initializers init(frame:) and init?(coder:).



                If you change



                let searchTextFieldView = SearchTextFieldView()


                with



                let searchTextFieldView = SearchTextFieldView(frame: CGRect(x: 50, y: 50, width: 100, height: 100))


                you will see the text.






                share|improve this answer
























                • This did not work. I forgot to mention in my question that I am using storyboard also I can see the textfield with placeholder text in it. Only problem is can not set text to it. Anything else you can suggest. Thanks.

                  – Nilesh
                  Nov 19 '18 at 8:49











                • So, are you trying to change text in view that was created programmatically, or that was added in storyboard. If it is the storyboard one, then you need to make an outlet and address it in your code.

                  – Evgeniy
                  Nov 19 '18 at 11:12
















                1














                You are creating you view via SearchTextFieldView(), while you have 2 available initializers init(frame:) and init?(coder:).



                If you change



                let searchTextFieldView = SearchTextFieldView()


                with



                let searchTextFieldView = SearchTextFieldView(frame: CGRect(x: 50, y: 50, width: 100, height: 100))


                you will see the text.






                share|improve this answer
























                • This did not work. I forgot to mention in my question that I am using storyboard also I can see the textfield with placeholder text in it. Only problem is can not set text to it. Anything else you can suggest. Thanks.

                  – Nilesh
                  Nov 19 '18 at 8:49











                • So, are you trying to change text in view that was created programmatically, or that was added in storyboard. If it is the storyboard one, then you need to make an outlet and address it in your code.

                  – Evgeniy
                  Nov 19 '18 at 11:12














                1












                1








                1







                You are creating you view via SearchTextFieldView(), while you have 2 available initializers init(frame:) and init?(coder:).



                If you change



                let searchTextFieldView = SearchTextFieldView()


                with



                let searchTextFieldView = SearchTextFieldView(frame: CGRect(x: 50, y: 50, width: 100, height: 100))


                you will see the text.






                share|improve this answer













                You are creating you view via SearchTextFieldView(), while you have 2 available initializers init(frame:) and init?(coder:).



                If you change



                let searchTextFieldView = SearchTextFieldView()


                with



                let searchTextFieldView = SearchTextFieldView(frame: CGRect(x: 50, y: 50, width: 100, height: 100))


                you will see the text.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 '18 at 7:47









                EvgeniyEvgeniy

                475413




                475413













                • This did not work. I forgot to mention in my question that I am using storyboard also I can see the textfield with placeholder text in it. Only problem is can not set text to it. Anything else you can suggest. Thanks.

                  – Nilesh
                  Nov 19 '18 at 8:49











                • So, are you trying to change text in view that was created programmatically, or that was added in storyboard. If it is the storyboard one, then you need to make an outlet and address it in your code.

                  – Evgeniy
                  Nov 19 '18 at 11:12



















                • This did not work. I forgot to mention in my question that I am using storyboard also I can see the textfield with placeholder text in it. Only problem is can not set text to it. Anything else you can suggest. Thanks.

                  – Nilesh
                  Nov 19 '18 at 8:49











                • So, are you trying to change text in view that was created programmatically, or that was added in storyboard. If it is the storyboard one, then you need to make an outlet and address it in your code.

                  – Evgeniy
                  Nov 19 '18 at 11:12

















                This did not work. I forgot to mention in my question that I am using storyboard also I can see the textfield with placeholder text in it. Only problem is can not set text to it. Anything else you can suggest. Thanks.

                – Nilesh
                Nov 19 '18 at 8:49





                This did not work. I forgot to mention in my question that I am using storyboard also I can see the textfield with placeholder text in it. Only problem is can not set text to it. Anything else you can suggest. Thanks.

                – Nilesh
                Nov 19 '18 at 8:49













                So, are you trying to change text in view that was created programmatically, or that was added in storyboard. If it is the storyboard one, then you need to make an outlet and address it in your code.

                – Evgeniy
                Nov 19 '18 at 11:12





                So, are you trying to change text in view that was created programmatically, or that was added in storyboard. If it is the storyboard one, then you need to make an outlet and address it in your code.

                – Evgeniy
                Nov 19 '18 at 11:12











                1














                You are not setting frame to the view. Also you are not loading the .xib in the view class. It should be like:-



                class SearchTextFieldView: UIView, UITextFieldDelegate{

                //MARK:- Initializer
                required init?(coder aDecoder: NSCoder) {
                super.init(coder: aDecoder)
                initialize(withFrame: self.bounds)
                }

                override init(frame : CGRect) {
                super.init(frame: frame)
                initialize(withFrame: frame)
                }

                //MARK: - View Initializers
                func initialize(withFrame frame : CGRect) {

                Bundle.main.loadNibNamed("SearchTextFieldView", owner: self, options: nil)
                view.frame = frame
                view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
                self.addSubview(view)
                initializeUI()
                }
                }


                Now you can call the below code in view controller:-



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

                func setupUI() {
                let searchTextFieldView = SearchTextFieldView(frame: ?*self.view.bounds)
                self.view.addSubview(searchTextFieldView)
                //adding view containing search box view at the top
                searchTextFieldView.searchText.text = "My Text"
                }


                Don't forget to create an xib with name "SearchTextFieldView.xib" as you are loading that nib in your initialize function.



                Hope it helps :)






                share|improve this answer






























                  1














                  You are not setting frame to the view. Also you are not loading the .xib in the view class. It should be like:-



                  class SearchTextFieldView: UIView, UITextFieldDelegate{

                  //MARK:- Initializer
                  required init?(coder aDecoder: NSCoder) {
                  super.init(coder: aDecoder)
                  initialize(withFrame: self.bounds)
                  }

                  override init(frame : CGRect) {
                  super.init(frame: frame)
                  initialize(withFrame: frame)
                  }

                  //MARK: - View Initializers
                  func initialize(withFrame frame : CGRect) {

                  Bundle.main.loadNibNamed("SearchTextFieldView", owner: self, options: nil)
                  view.frame = frame
                  view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
                  self.addSubview(view)
                  initializeUI()
                  }
                  }


                  Now you can call the below code in view controller:-



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

                  func setupUI() {
                  let searchTextFieldView = SearchTextFieldView(frame: ?*self.view.bounds)
                  self.view.addSubview(searchTextFieldView)
                  //adding view containing search box view at the top
                  searchTextFieldView.searchText.text = "My Text"
                  }


                  Don't forget to create an xib with name "SearchTextFieldView.xib" as you are loading that nib in your initialize function.



                  Hope it helps :)






                  share|improve this answer




























                    1












                    1








                    1







                    You are not setting frame to the view. Also you are not loading the .xib in the view class. It should be like:-



                    class SearchTextFieldView: UIView, UITextFieldDelegate{

                    //MARK:- Initializer
                    required init?(coder aDecoder: NSCoder) {
                    super.init(coder: aDecoder)
                    initialize(withFrame: self.bounds)
                    }

                    override init(frame : CGRect) {
                    super.init(frame: frame)
                    initialize(withFrame: frame)
                    }

                    //MARK: - View Initializers
                    func initialize(withFrame frame : CGRect) {

                    Bundle.main.loadNibNamed("SearchTextFieldView", owner: self, options: nil)
                    view.frame = frame
                    view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
                    self.addSubview(view)
                    initializeUI()
                    }
                    }


                    Now you can call the below code in view controller:-



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

                    func setupUI() {
                    let searchTextFieldView = SearchTextFieldView(frame: ?*self.view.bounds)
                    self.view.addSubview(searchTextFieldView)
                    //adding view containing search box view at the top
                    searchTextFieldView.searchText.text = "My Text"
                    }


                    Don't forget to create an xib with name "SearchTextFieldView.xib" as you are loading that nib in your initialize function.



                    Hope it helps :)






                    share|improve this answer















                    You are not setting frame to the view. Also you are not loading the .xib in the view class. It should be like:-



                    class SearchTextFieldView: UIView, UITextFieldDelegate{

                    //MARK:- Initializer
                    required init?(coder aDecoder: NSCoder) {
                    super.init(coder: aDecoder)
                    initialize(withFrame: self.bounds)
                    }

                    override init(frame : CGRect) {
                    super.init(frame: frame)
                    initialize(withFrame: frame)
                    }

                    //MARK: - View Initializers
                    func initialize(withFrame frame : CGRect) {

                    Bundle.main.loadNibNamed("SearchTextFieldView", owner: self, options: nil)
                    view.frame = frame
                    view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
                    self.addSubview(view)
                    initializeUI()
                    }
                    }


                    Now you can call the below code in view controller:-



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

                    func setupUI() {
                    let searchTextFieldView = SearchTextFieldView(frame: ?*self.view.bounds)
                    self.view.addSubview(searchTextFieldView)
                    //adding view containing search box view at the top
                    searchTextFieldView.searchText.text = "My Text"
                    }


                    Don't forget to create an xib with name "SearchTextFieldView.xib" as you are loading that nib in your initialize function.



                    Hope it helps :)







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 19 '18 at 7:59

























                    answered Nov 19 '18 at 7:54









                    Pratyush PratikPratyush Pratik

                    471410




                    471410























                        1














                        add frame for the searchTextFieldView inside setupUI() method. because the View got loaded on the view but its doesn't have a frame (x,y position, width and height). Change your UIViewController's colour to grey and u can see the your view loaded on the left corner (0,0). set frame size for the view that will solve this problem.






                        share|improve this answer




























                          1














                          add frame for the searchTextFieldView inside setupUI() method. because the View got loaded on the view but its doesn't have a frame (x,y position, width and height). Change your UIViewController's colour to grey and u can see the your view loaded on the left corner (0,0). set frame size for the view that will solve this problem.






                          share|improve this answer


























                            1












                            1








                            1







                            add frame for the searchTextFieldView inside setupUI() method. because the View got loaded on the view but its doesn't have a frame (x,y position, width and height). Change your UIViewController's colour to grey and u can see the your view loaded on the left corner (0,0). set frame size for the view that will solve this problem.






                            share|improve this answer













                            add frame for the searchTextFieldView inside setupUI() method. because the View got loaded on the view but its doesn't have a frame (x,y position, width and height). Change your UIViewController's colour to grey and u can see the your view loaded on the left corner (0,0). set frame size for the view that will solve this problem.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 19 '18 at 8:03









                            SarathSarath

                            100110




                            100110






























                                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.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370102%2fchanging-variables-of-a-custom-uiview-in-another-custom-viewcontroller%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

                                How to change which sound is reproduced for terminal bell?

                                Can I use Tabulator js library in my java Spring + Thymeleaf project?

                                Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents