In iOS: Problem solving for automatic offset of Uiscrollview in navigation controller

Source: Internet
Author: User

When you add a Uiscrollviewcontroller directly to a navigation under a Uiviewcontroller, Uiscrollview automatically offsets 20 points (which may be offset by 64 points, 84 points)-(depending on your settings, it will be offset anyway), resulting in a comparison of the reasons, but the solution is simple:

Solution:

Do not put Uiscrollview directly on the controller, you can first create an unrelated uiview to do cannon fodder;

In the place to put Uiscrollview, first put on cannon fodder UIView

There is UIView point cushion back, and then put Uiscrollview on the top will not be offset;

The detailed code is as follows:


#pragmaMark-viewdidload-(void) viewdidload {[Super viewdidload]; //self.automaticallyadjustsscrollviewinsets = NO;//Self.navigationController.navigationBarHidden = YES; ///Viewback solve the problem of automatic migration of Totalview (Cannon view)UIView * Viewback = [[UIView alloc] Initwithframe:cgrectmake (0, -, -, -)]; Viewback.backgroundcolor=[Uicolor Greencolor]; Self.totalScrollView.backgroundColor=[Uicolor Purplecolor]; [Self.view Addsubview:viewback]; [Self.view AddSubview:self.totalScrollView];
ScrollView Initialization by lazy loading
_totalscrollview = [[Uiscrollview alloc] Initwithframe:cgrectmake (0, 64, 375, 667)]; }

In iOS: Problem solving for automatic offset of Uiscrollview in navigation controller

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.