Processing iPhone 3.5inch and IPhone 4-inch display (UIScrollView)

It's hard for me to deal with the layout design, which is suitable for both iPhone 3.5inch and iPhone 5 (simulators). I checked the automatic layout and all the layouts were perfect. However, now I need to use UIScrollView, and therefore you need to uncheck the auto-layout.

Also, when viewing the layout with the iPhone 4-inch display, it adds about 60 pixels at the top of the UIScrollView.

Is there a better way to do this (configure scrollview without canceling auto layout)? Therefore, I can support iPhone 4.

//to set up the scrollview
[self.scrollView setScrollEnabled:YES];
[self.scrollView setContentSize:CGSizeMake(320, 800)];

however, it does not scroll until I turn off auto power off. Is there a better way to do this?

+4
source share
4 answers

Try this (this solved my problem):

scrollView addConstraint:[NSLayoutConstraint constraintWithItem:lastSubView
                                         attribute:NSLayoutAttributeRight
                                         relatedBy:NSLayoutRelationEqual
                                            toItem:scrollView
                                         attribute:NSLayoutAttributeRight
                                        multiplier:1.0
                                          constant:0]];

REFERENCE: UIScrollView does not use autodetection restrictions

0
source

Try autoresist,

 self.scrollView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin);
+1
source

UIScrollView Autolayout . . .

0

- UIScrollView frame. CGRect.

CGRect rect=[[UIScreen mainScreen] bounds];

, .

0

All Articles