Is there a way to programmatically control UIScrollView? As in the case of obtaining a value for its location, so how far does it scroll and something changes and its position changes, scroll it programmatically?
Hope you can help, thanks.
I donβt know what @Alexandergre or @JAgostoni are talking about. Scrolling in UIScrollView is very simple.
I suggest you familiarize yourself with the documentation for UIScrollView: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html
To scroll through a UIScrollView just use
- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated
Example:
[myScrollView scrollRectToVisible:CGRectMake(20, 20, 320, 480) animated:YES];
This will scroll the UIScrollView with animation up to 20 along the x axis, 20 along the height and width of y and 320x480.
If you want to get information about your view (for example, which frame is visible), you should use the methods and properties from UIView, since it is the parent of UIScrollView. Check out the UIView documentation at: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html
To get a visible frame, use
myScrollView.frame;
Do not mix it with content size
myScrollView.contentSize;
But as I said. Use the documentation!
You can scroll UIScrollView with
scrollView.contentOffset = CGPointMake(x, y);
If you want the scroll to be animated, use UIview animation
[UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.75]; [UIView setAnimationDelegate:self]; scrollView.contentOffset = CGPointMake(x, y); [UIView commitAnimations];
To get the content offset, create a CGPoint to get the offset value:
CGPoint value; value = scrollview.contentOffset;
Try this :- -(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{ //NSLog(@"%f %f", scrollView.contentOffset.y, scrollView.contentSize.height); } -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ //NSLog(@"scrollViewDidEndDecelerating"); } -(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView{ //NSLog(@"scrollViewDidEndScrollingAnimation"); } //Update the value of rol -(void)scrollViewDidScroll:(UIScrollView *)scrollView{ if(scrollView==MainScrollVw){//Main Scroll View All Fns Start,,, int rol_y= MainScrollVw.contentOffset.y; //int rol_x= MainScrollVw.contentOffset.x; if(rol_y>0){ [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.30]; MainMenuVw.frame= CGRectMake(0 ,0 ,self.view.frame.size.width ,75); [UIView commitAnimations]; }else{ [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.30]; MainMenuVw.frame= CGRectMake(0 ,0 ,self.view.frame.size.width ,150); [UIView commitAnimations]; } } }
Yeah. Take a look at this post and let me know if this helps: http://jason.agostoni.net/2011/02/12/ipad-resize-view-to-account-for-keyboard/
This is specifically for working with the keyboard, but I explain there how to get the scroll position and set it, etc. Of course, using Apple documentation.
Source: https://habr.com/ru/post/926366/More articles:Is the width of an html element less than the sum of the width of the individual child elements? - jqueryJunit using ActivityInstrumentationTestCase2 - Conception Exception: Stub - androidSet Content Offset to View Scroll - iosFree up memory: how to delete variables when I put them on - VBA VB ACCESS - vbaReading XML resource file in WinRT Javascript application - javascriptJersey client does not set Content-Length - javaHow to get given parameter values ββfrom sql server in application outside crm - c #Is it possible to simultaneously receive and package packets in iptables - linuxHow to run Android system application without root permisson? - androidHow to set current record BindingSource to null? - data-bindingAll Articles