How to make header view clickable of tableview in Swift










0















is there any way to make header view of tableview clickable so that can navigate to another viewcontroller.



image



I am trying to make the same design as there is a team "Chelsea" (section header and it is clickable) and which contains 2 cell of different type(both are clickable). so , what approach should I follow to create the same design.
or please suggest any other way for doing this.










share|improve this question



















  • 1





    yes put a view on it use UITapGesture

    – wings
    Nov 14 '18 at 12:15











  • You can use collcetionview with flowlayout

    – SPatel
    Nov 14 '18 at 12:17











  • @SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell

    – harinder rana
    Nov 14 '18 at 12:19












  • one team group = one section

    – SPatel
    Nov 14 '18 at 12:23











  • use supplementary view for header

    – SPatel
    Nov 14 '18 at 12:24















0















is there any way to make header view of tableview clickable so that can navigate to another viewcontroller.



image



I am trying to make the same design as there is a team "Chelsea" (section header and it is clickable) and which contains 2 cell of different type(both are clickable). so , what approach should I follow to create the same design.
or please suggest any other way for doing this.










share|improve this question



















  • 1





    yes put a view on it use UITapGesture

    – wings
    Nov 14 '18 at 12:15











  • You can use collcetionview with flowlayout

    – SPatel
    Nov 14 '18 at 12:17











  • @SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell

    – harinder rana
    Nov 14 '18 at 12:19












  • one team group = one section

    – SPatel
    Nov 14 '18 at 12:23











  • use supplementary view for header

    – SPatel
    Nov 14 '18 at 12:24













0












0








0


1






is there any way to make header view of tableview clickable so that can navigate to another viewcontroller.



image



I am trying to make the same design as there is a team "Chelsea" (section header and it is clickable) and which contains 2 cell of different type(both are clickable). so , what approach should I follow to create the same design.
or please suggest any other way for doing this.










share|improve this question
















is there any way to make header view of tableview clickable so that can navigate to another viewcontroller.



image



I am trying to make the same design as there is a team "Chelsea" (section header and it is clickable) and which contains 2 cell of different type(both are clickable). so , what approach should I follow to create the same design.
or please suggest any other way for doing this.







ios swift tableview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 14:51









Cœur

18.2k9108148




18.2k9108148










asked Nov 14 '18 at 12:13









harinder ranaharinder rana

177




177







  • 1





    yes put a view on it use UITapGesture

    – wings
    Nov 14 '18 at 12:15











  • You can use collcetionview with flowlayout

    – SPatel
    Nov 14 '18 at 12:17











  • @SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell

    – harinder rana
    Nov 14 '18 at 12:19












  • one team group = one section

    – SPatel
    Nov 14 '18 at 12:23











  • use supplementary view for header

    – SPatel
    Nov 14 '18 at 12:24












  • 1





    yes put a view on it use UITapGesture

    – wings
    Nov 14 '18 at 12:15











  • You can use collcetionview with flowlayout

    – SPatel
    Nov 14 '18 at 12:17











  • @SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell

    – harinder rana
    Nov 14 '18 at 12:19












  • one team group = one section

    – SPatel
    Nov 14 '18 at 12:23











  • use supplementary view for header

    – SPatel
    Nov 14 '18 at 12:24







1




1





yes put a view on it use UITapGesture

– wings
Nov 14 '18 at 12:15





yes put a view on it use UITapGesture

– wings
Nov 14 '18 at 12:15













You can use collcetionview with flowlayout

– SPatel
Nov 14 '18 at 12:17





You can use collcetionview with flowlayout

– SPatel
Nov 14 '18 at 12:17













@SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell

– harinder rana
Nov 14 '18 at 12:19






@SPatel is collecetionview will solve this problem as there are multiple clickable cell at one row......one team group look like one cell

– harinder rana
Nov 14 '18 at 12:19














one team group = one section

– SPatel
Nov 14 '18 at 12:23





one team group = one section

– SPatel
Nov 14 '18 at 12:23













use supplementary view for header

– SPatel
Nov 14 '18 at 12:24





use supplementary view for header

– SPatel
Nov 14 '18 at 12:24












2 Answers
2






active

oldest

votes


















1














You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView



-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section





share|improve this answer






























    0














    header view of tableview are buttons, or you could use tap gesture.



    header view has a block property, you could write your business in .



    optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?


    And you can use delegate pattern.



    There ie no api like



    optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)


    for tableView



    like this



    var callback: (() -> Void)!


    var label = UILabel()

    override init(frame: CGRect)
    super.init(frame: frame)
    label.isUserInteractionEnabled = true
    let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
    label.addGestureRecognizer(tap)



    @objc func do_it()
    callback()






    share|improve this answer

























    • how we can target the headerview in tap gesture? @dengApro

      – harinder rana
      Nov 14 '18 at 12:28










    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%2f53299998%2fhow-to-make-header-view-clickable-of-tableview-in-swift%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView



    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section





    share|improve this answer



























      1














      You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView



      -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

      -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section





      share|improve this answer

























        1












        1








        1







        You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView



        -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

        -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section





        share|improve this answer













        You can implement below methods and in viewForHeaderInSection: you can define UIButton or you can add tap gesture on UIView



        -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

        -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 12:50









        Kiran PadhiyarKiran Padhiyar

        113




        113























            0














            header view of tableview are buttons, or you could use tap gesture.



            header view has a block property, you could write your business in .



            optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?


            And you can use delegate pattern.



            There ie no api like



            optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)


            for tableView



            like this



            var callback: (() -> Void)!


            var label = UILabel()

            override init(frame: CGRect)
            super.init(frame: frame)
            label.isUserInteractionEnabled = true
            let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
            label.addGestureRecognizer(tap)



            @objc func do_it()
            callback()






            share|improve this answer

























            • how we can target the headerview in tap gesture? @dengApro

              – harinder rana
              Nov 14 '18 at 12:28















            0














            header view of tableview are buttons, or you could use tap gesture.



            header view has a block property, you could write your business in .



            optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?


            And you can use delegate pattern.



            There ie no api like



            optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)


            for tableView



            like this



            var callback: (() -> Void)!


            var label = UILabel()

            override init(frame: CGRect)
            super.init(frame: frame)
            label.isUserInteractionEnabled = true
            let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
            label.addGestureRecognizer(tap)



            @objc func do_it()
            callback()






            share|improve this answer

























            • how we can target the headerview in tap gesture? @dengApro

              – harinder rana
              Nov 14 '18 at 12:28













            0












            0








            0







            header view of tableview are buttons, or you could use tap gesture.



            header view has a block property, you could write your business in .



            optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?


            And you can use delegate pattern.



            There ie no api like



            optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)


            for tableView



            like this



            var callback: (() -> Void)!


            var label = UILabel()

            override init(frame: CGRect)
            super.init(frame: frame)
            label.isUserInteractionEnabled = true
            let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
            label.addGestureRecognizer(tap)



            @objc func do_it()
            callback()






            share|improve this answer















            header view of tableview are buttons, or you could use tap gesture.



            header view has a block property, you could write your business in .



            optional public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?


            And you can use delegate pattern.



            There ie no api like



            optional public func tableView(_ tableView: UITableView, didSelectHeaderAt indexPath: IndexPath)


            for tableView



            like this



            var callback: (() -> Void)!


            var label = UILabel()

            override init(frame: CGRect)
            super.init(frame: frame)
            label.isUserInteractionEnabled = true
            let tap = UITapGestureRecognizer(target: self, action: #selector(self.do_it))
            label.addGestureRecognizer(tap)



            @objc func do_it()
            callback()







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 14 '18 at 12:37

























            answered Nov 14 '18 at 12:22









            dengAprodengApro

            1,06411122




            1,06411122












            • how we can target the headerview in tap gesture? @dengApro

              – harinder rana
              Nov 14 '18 at 12:28

















            • how we can target the headerview in tap gesture? @dengApro

              – harinder rana
              Nov 14 '18 at 12:28
















            how we can target the headerview in tap gesture? @dengApro

            – harinder rana
            Nov 14 '18 at 12:28





            how we can target the headerview in tap gesture? @dengApro

            – harinder rana
            Nov 14 '18 at 12:28

















            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%2f53299998%2fhow-to-make-header-view-clickable-of-tableview-in-swift%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







            這個網誌中的熱門文章

            What does pagestruct do in Eviews?

            Dutch intervention in Lombok and Karangasem

            Channel Islands