UIScrollView (1) Basic UIScrollView usage and proxy method, uiscrollview proxy
- (
void
)viewDidLoad
{
[super viewDidLoad];
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
scrollView.backgroundColor = [UIColor redColor];
// Whether sliding to the top is supported
// scrollView.scrollsToTop = NO;
scrollView.delegate = self;
// Set the content size
scrollView.contentSize = CGSizeMake(320, 460*10);
// Whether to rebound
// scrollView.bounces = NO;
// Whether the page is displayed
// scrollView.pagingEnabled = YES;
// Whether to scroll
// scrollView.scrollEnabled = NO;
// scrollView.showsHorizontalScrollIndicator = NO;
// Set the indicator Style
// scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
// Set the content edge and Indicators edge
// scrollView.contentInset = UIEdgeInsetsMake(0, 50, 50, 0);
// scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 50, 0, 0);
// Prompt the user, Indicators flash
[scrollView flashScrollIndicators];
// Whether or not the movement is at the same time, lock
scrollView.directionalLockEnabled = YES;
[self.view addSubview:scrollView];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, 320, 40)];
label.backgroundColor = [UIColor yellowColor];
label.text = @
"Learn scrolleview"
;
[scrollView addSubview:label];
[label release];
}
#pragma mark -
/*
// Return a magnified or zoomed-out view
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
}
// Start to zoom in or out
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:
(UIView *)view
{
}
// End of Scaling
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
}
// The view has been zoomed in or out.
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
{
NSLog(@"scrollViewDidScrollToTop");
}
*/
// Whether sliding to the top is supported
- (
BOOL
)scrollViewShouldScrollToTop:(UIScrollView *)scrollView
{
return
YES;
}
// Call this method when sliding to the top
- (
void
)scrollViewDidScrollToTop:(UIScrollView *)scrollView
{
NSLog(@
"scrollViewDidScrollToTop"
);
}
// ScrollView slides
- (
void
)scrollViewDidScroll:(UIScrollView *)scrollView
{
NSLog(@
"scrollViewDidScroll"
);
}
// Start dragging scrollView
- (
void
)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
NSLog(@
"scrollViewWillBeginDragging"
);
}
// Drag the scrollView to the end
- (
void
)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(
BOOL
)decelerate
{
NSLog(@
"scrollViewDidEndDragging"
);
}
// ScrollView starts to slow down (the following two methods must be different from the above two methods)
- (
void
)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
NSLog(@
"scrollViewWillBeginDecelerating"
);
}
// Scrollview stop
- (
void
)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@
"scrollViewDidEndDecelerating"
);
}