iOS - UIScrollView not scrolling, though scroll bar is shown











up vote
0
down vote

favorite












I have a Scroll View, and inside it a UIView called "Content View", that contains all of my elements.



enter image description here



The Content view is equal to the Scroll view's top, bottom, leading and trailing. Also equal its width & height.



I also added self.scrollView.contentSize = self.contentView.frame.size
in ViewDidLoad.



When I scroll I can see a scroll bar going up and down on the side, and it seems like the page length is correct according to the bar, but the content itself does not scroll as you can see here:



enter image description here



What am I doing wrong?



Thanks!










share|improve this question




















  • 1




    It Seems the content is not inside the scrollView. The scrollView is on top of contentView, Check the view hierarchy
    – Janmenjaya
    Nov 19 at 11:57










  • can you remove safe area from the scroll view once and try?
    – Aakash
    Nov 19 at 11:58










  • I agree with @Janmenjaya please post your full view hierarchy
    – Reinier Melian
    Nov 19 at 12:04










  • @Janmenjaya I posted the full hierarchy, you can see the content view is indented under the scroll view.
    – Rotem Yakov
    Nov 19 at 12:41












  • @Aakash how can I delete a safe area?
    – Rotem Yakov
    Nov 19 at 12:42















up vote
0
down vote

favorite












I have a Scroll View, and inside it a UIView called "Content View", that contains all of my elements.



enter image description here



The Content view is equal to the Scroll view's top, bottom, leading and trailing. Also equal its width & height.



I also added self.scrollView.contentSize = self.contentView.frame.size
in ViewDidLoad.



When I scroll I can see a scroll bar going up and down on the side, and it seems like the page length is correct according to the bar, but the content itself does not scroll as you can see here:



enter image description here



What am I doing wrong?



Thanks!










share|improve this question




















  • 1




    It Seems the content is not inside the scrollView. The scrollView is on top of contentView, Check the view hierarchy
    – Janmenjaya
    Nov 19 at 11:57










  • can you remove safe area from the scroll view once and try?
    – Aakash
    Nov 19 at 11:58










  • I agree with @Janmenjaya please post your full view hierarchy
    – Reinier Melian
    Nov 19 at 12:04










  • @Janmenjaya I posted the full hierarchy, you can see the content view is indented under the scroll view.
    – Rotem Yakov
    Nov 19 at 12:41












  • @Aakash how can I delete a safe area?
    – Rotem Yakov
    Nov 19 at 12:42













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a Scroll View, and inside it a UIView called "Content View", that contains all of my elements.



enter image description here



The Content view is equal to the Scroll view's top, bottom, leading and trailing. Also equal its width & height.



I also added self.scrollView.contentSize = self.contentView.frame.size
in ViewDidLoad.



When I scroll I can see a scroll bar going up and down on the side, and it seems like the page length is correct according to the bar, but the content itself does not scroll as you can see here:



enter image description here



What am I doing wrong?



Thanks!










share|improve this question















I have a Scroll View, and inside it a UIView called "Content View", that contains all of my elements.



enter image description here



The Content view is equal to the Scroll view's top, bottom, leading and trailing. Also equal its width & height.



I also added self.scrollView.contentSize = self.contentView.frame.size
in ViewDidLoad.



When I scroll I can see a scroll bar going up and down on the side, and it seems like the page length is correct according to the bar, but the content itself does not scroll as you can see here:



enter image description here



What am I doing wrong?



Thanks!







ios objective-c xcode uiscrollview interface-builder






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 13:48

























asked Nov 19 at 11:54









Rotem Yakov

4118




4118








  • 1




    It Seems the content is not inside the scrollView. The scrollView is on top of contentView, Check the view hierarchy
    – Janmenjaya
    Nov 19 at 11:57










  • can you remove safe area from the scroll view once and try?
    – Aakash
    Nov 19 at 11:58










  • I agree with @Janmenjaya please post your full view hierarchy
    – Reinier Melian
    Nov 19 at 12:04










  • @Janmenjaya I posted the full hierarchy, you can see the content view is indented under the scroll view.
    – Rotem Yakov
    Nov 19 at 12:41












  • @Aakash how can I delete a safe area?
    – Rotem Yakov
    Nov 19 at 12:42














  • 1




    It Seems the content is not inside the scrollView. The scrollView is on top of contentView, Check the view hierarchy
    – Janmenjaya
    Nov 19 at 11:57










  • can you remove safe area from the scroll view once and try?
    – Aakash
    Nov 19 at 11:58










  • I agree with @Janmenjaya please post your full view hierarchy
    – Reinier Melian
    Nov 19 at 12:04










  • @Janmenjaya I posted the full hierarchy, you can see the content view is indented under the scroll view.
    – Rotem Yakov
    Nov 19 at 12:41












  • @Aakash how can I delete a safe area?
    – Rotem Yakov
    Nov 19 at 12:42








1




1




It Seems the content is not inside the scrollView. The scrollView is on top of contentView, Check the view hierarchy
– Janmenjaya
Nov 19 at 11:57




It Seems the content is not inside the scrollView. The scrollView is on top of contentView, Check the view hierarchy
– Janmenjaya
Nov 19 at 11:57












can you remove safe area from the scroll view once and try?
– Aakash
Nov 19 at 11:58




can you remove safe area from the scroll view once and try?
– Aakash
Nov 19 at 11:58












I agree with @Janmenjaya please post your full view hierarchy
– Reinier Melian
Nov 19 at 12:04




I agree with @Janmenjaya please post your full view hierarchy
– Reinier Melian
Nov 19 at 12:04












@Janmenjaya I posted the full hierarchy, you can see the content view is indented under the scroll view.
– Rotem Yakov
Nov 19 at 12:41






@Janmenjaya I posted the full hierarchy, you can see the content view is indented under the scroll view.
– Rotem Yakov
Nov 19 at 12:41














@Aakash how can I delete a safe area?
– Rotem Yakov
Nov 19 at 12:42




@Aakash how can I delete a safe area?
– Rotem Yakov
Nov 19 at 12:42












2 Answers
2






active

oldest

votes

















up vote
1
down vote














The Content view is equal to the Scroll view's top, bottom, leading
and trailing. Also equal its width & height.




You need to remove the width and height constraints. Top, bottom, leading and trailing should stay. Also, remove that contentSize setting from viewDidLoad.



I assume you want vertical scroll. In that case, you should set contentView's width constraint to be equal to View's width (not scrollView's but View's which is the root of the hierarchy).



That should do the trick, assuming that vertical constraints of contentView's children are properly set up.






share|improve this answer




























    up vote
    0
    down vote



    accepted










    The 1st thing I had to do is what user3199693 said: remove that line from viewDidLoad (that made the wrong scroll bar I saw to go away). Also I set contentView's width constraint to be equal to top View's width, as he said.



    That was good, but still didn't solve the problem. What did help was equal the height of the content view with top view.



    Got the idea from here.






    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',
      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%2f53374095%2fios-uiscrollview-not-scrolling-though-scroll-bar-is-shown%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








      up vote
      1
      down vote














      The Content view is equal to the Scroll view's top, bottom, leading
      and trailing. Also equal its width & height.




      You need to remove the width and height constraints. Top, bottom, leading and trailing should stay. Also, remove that contentSize setting from viewDidLoad.



      I assume you want vertical scroll. In that case, you should set contentView's width constraint to be equal to View's width (not scrollView's but View's which is the root of the hierarchy).



      That should do the trick, assuming that vertical constraints of contentView's children are properly set up.






      share|improve this answer

























        up vote
        1
        down vote














        The Content view is equal to the Scroll view's top, bottom, leading
        and trailing. Also equal its width & height.




        You need to remove the width and height constraints. Top, bottom, leading and trailing should stay. Also, remove that contentSize setting from viewDidLoad.



        I assume you want vertical scroll. In that case, you should set contentView's width constraint to be equal to View's width (not scrollView's but View's which is the root of the hierarchy).



        That should do the trick, assuming that vertical constraints of contentView's children are properly set up.






        share|improve this answer























          up vote
          1
          down vote










          up vote
          1
          down vote










          The Content view is equal to the Scroll view's top, bottom, leading
          and trailing. Also equal its width & height.




          You need to remove the width and height constraints. Top, bottom, leading and trailing should stay. Also, remove that contentSize setting from viewDidLoad.



          I assume you want vertical scroll. In that case, you should set contentView's width constraint to be equal to View's width (not scrollView's but View's which is the root of the hierarchy).



          That should do the trick, assuming that vertical constraints of contentView's children are properly set up.






          share|improve this answer













          The Content view is equal to the Scroll view's top, bottom, leading
          and trailing. Also equal its width & height.




          You need to remove the width and height constraints. Top, bottom, leading and trailing should stay. Also, remove that contentSize setting from viewDidLoad.



          I assume you want vertical scroll. In that case, you should set contentView's width constraint to be equal to View's width (not scrollView's but View's which is the root of the hierarchy).



          That should do the trick, assuming that vertical constraints of contentView's children are properly set up.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 at 21:41









          user3199693

          5339




          5339
























              up vote
              0
              down vote



              accepted










              The 1st thing I had to do is what user3199693 said: remove that line from viewDidLoad (that made the wrong scroll bar I saw to go away). Also I set contentView's width constraint to be equal to top View's width, as he said.



              That was good, but still didn't solve the problem. What did help was equal the height of the content view with top view.



              Got the idea from here.






              share|improve this answer



























                up vote
                0
                down vote



                accepted










                The 1st thing I had to do is what user3199693 said: remove that line from viewDidLoad (that made the wrong scroll bar I saw to go away). Also I set contentView's width constraint to be equal to top View's width, as he said.



                That was good, but still didn't solve the problem. What did help was equal the height of the content view with top view.



                Got the idea from here.






                share|improve this answer

























                  up vote
                  0
                  down vote



                  accepted







                  up vote
                  0
                  down vote



                  accepted






                  The 1st thing I had to do is what user3199693 said: remove that line from viewDidLoad (that made the wrong scroll bar I saw to go away). Also I set contentView's width constraint to be equal to top View's width, as he said.



                  That was good, but still didn't solve the problem. What did help was equal the height of the content view with top view.



                  Got the idea from here.






                  share|improve this answer














                  The 1st thing I had to do is what user3199693 said: remove that line from viewDidLoad (that made the wrong scroll bar I saw to go away). Also I set contentView's width constraint to be equal to top View's width, as he said.



                  That was good, but still didn't solve the problem. What did help was equal the height of the content view with top view.



                  Got the idea from here.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 22 at 10:59

























                  answered Nov 20 at 14:26









                  Rotem Yakov

                  4118




                  4118






























                      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%2f53374095%2fios-uiscrollview-not-scrolling-though-scroll-bar-is-shown%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

                      Costa Masnaga

                      Fotorealismo

                      Sidney Franklin