UIScrollView is one of the most important and useful controls in iOS. It is the basis for the very popular UITableView and is a great way to present content larger than a single screen.
You must set the contentSize property to the size of the scrollable content. This specifies the size of the scrollable area |
Answer:
[scrollView setContentOffset:CGPointMake(x, y) animated:YES];
Read:
Top iOS interview Questions And Answers Collection
2.How to Scroll UIScrollView scroll to bottom programmatically?
Answer:
CGPoint bottomOffset = CGPointMake(0, self.scrollView.contentSize.height - self.scrollView.bounds.size.height);
[self.scrollView setContentOffset:bottomOffset animated:YES];
Read:
iOS Interview Questions And Answers For 1-2 years Experienced Candidates.
3.How to Scroll a UIScrollView to top programmatically?
Answer:
[self.scrollView setContentOffset:CGPointMake(self.scrollView.contentOffset.x, 0)
animated:YES];
Read:
iOS Interview Questions And Answers Part 25
4.How to implement page-scroll using UIScrollView programmatically in iOS?
Answer:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
CGFloat pageWidth = scrollView.frame.size.width;
int currentPage = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
pageControl.currentPage = currentPage;
}
Read:
Most Important iPhone interview Questions and Answers
5.How to detect UIScrollView Scroll direction programmatically in iOS?
Answer:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
self.lastPage = self.currentPage;
CGFloat pageWidth = _mainScrollView.frame.size.width;
self.currentPage = floor((_mainScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
if (self.lastPage < self.currentPage) {
NSLog(@"Right Direction");
}else if(self.lastPage > self.currentPage){
NSLog(@"Left Direction");
}else if (self.lastPage == self.currentPage){
//same page
NSLog(@"Same Page");
}
}
Read:
How to animate a checkmark Using Bezier path as Clipping Mask in iOS
iPhone Core Animation - Drawing a Circle
How to make UIView with rounded corners?
Animating a UIView to curl down,curl up,curl right,curl left
How to create a Coin Fall Animation
How to animate a view or image along a curved path.
How to create a twinkling star background effect in iOS ?