UIScrollView Scroll Changes Subtitle Frames

My application uses storyboards and autorun. In the view controller, I created UIScrollViewand added three subqueries.

At runtime, I need to resize the subzones and reorder them. Initially, I rebuild them in viewDidLayoutSubviews, and it seems to work until I scroll the scroll. Then the subtask framework is changed back to the sizes set in IB. (I set the size of the content UIScrollViewwhen rearranging the views and deleting all UIViewConstraints.)

+4
source share
2 answers

Auto Layout . Auto Layout, , . Auto Layout , UIView.

:

  • , , .
  • xib, Auto Layout xib.
+2

. . uiscrollview 3-4 . . , , , . :

- (void) growImg {

if (self.growImgNeed) {

    self.Scroller.frame=CGRectMake(0, 100, 320, 376);
    CGRect ViewSize = Scroller.bounds;
    for(int i=0;i< Scroller.subviews.count;i++){
        [[self.Scroller.subviews objectAtIndex:i] setSize:CGSizeMake(320, 376)];
        [[self.Scroller.subviews objectAtIndex:i] setFrame:ViewSize];
        ViewSize = CGRectOffset(ViewSize, Scroller.bounds.size.width, 0);
        }
    Scroller.contentSize = CGSizeMake((Scroller.subviews.count) * Scroller.bounds.size.width, Scroller.bounds.size.height);
    self.growImgNeed=false;
}

else {
    self.Scroller.frame=CGRectMake(80, 82, 160, 188);
    CGRect ViewSize = Scroller.bounds;
    for(int i=0;i< Scroller.subviews.count;i++){
        [[self.Scroller.subviews objectAtIndex:i] setSize:CGSizeMake(160, 188)];
        [[self.Scroller.subviews objectAtIndex:i] setFrame:ViewSize];
        ViewSize = CGRectOffset(ViewSize, Scroller.bounds.size.width, 0);
    }
    Scroller.contentSize = CGSizeMake((Scroller.subviews.count) * Scroller.bounds.size.width, Scroller.bounds.size.height);
    self.growImgNeed=true;

}

}

0

Source: https://habr.com/ru/post/1526289/


All Articles