Use of ScrollView, and scrollview
1. UIScrollView has two sub-classes: uitextview and uitableview. These two controls are frequently used. Therefore, it is necessary to master their usage. They provide horizontal or vertical scroll bars when the content exceeds the screen.
2. Three main attributes: contentSize, contentInset, and contentOffset.
2.1 first,Be sure to set contentSize(The size occupied by the actual content in the control) This attribute must be set to a greater range than that displayed on the control screen to display the scroll effect.
For example, if the size of a scrollview is (), you can set the size as follows to display the content in the range () through the scroll bar.
- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.scrollView.contentSize = CGSizeMake(900, 1200);}
2.2 contentInset this attribute is a blank size of the border, relatively simple.
2.3ContentOffsetNote that this attribute is used to set the display range of the Start Control.
For example, if you want to make the initial display of content with an offset of 200 in the y direction, the following settings will show the dynamic effect of moving 200 downward.
-(void)viewDidAppear:(BOOL)animated
{ [self.scrollView setContentOffset:CGPointMake(0, 200) animated:YES];}
3. Remember to cancel the check option in the story board.Use auto layoutOtherwise, scrollview scrolling fails.
All of the above are simple to use and will be supplemented in the future.