{"id":5240,"date":"2014-03-30T19:59:45","date_gmt":"2014-03-30T19:59:45","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/loading-dynamical-images-to-uiscrollview-collection-of-common-programming-errors\/"},"modified":"2014-03-30T19:59:45","modified_gmt":"2014-03-30T19:59:45","slug":"loading-dynamical-images-to-uiscrollview-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/loading-dynamical-images-to-uiscrollview-collection-of-common-programming-errors\/","title":{"rendered":"Loading dynamical images to UIScrollVIew-Collection of common programming errors"},"content":{"rendered":"<pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView{\n\n    float currPos = scroll.contentOffset.x;\n\n    BOOL movingRight = ( currPos \/ scroll.frame.size.width ) &gt; 1 ? YES : NO ;\n\n    if (movingRight) {\n        NSLog(@\"RIGHT\");\n        [photo2 setImage:[UIImage imageNamed:@\"22.jpg\"]];\n        photo2.frame = CGRectMake(scroll.frame.size.width * 2, 0, scroll.frame.size.width, scroll.frame.size.height); \n    }else{\n        NSLog(@\"LEFT\");\n        [photo2 setImage:[UIImage imageNamed:@\"33.jpg\"]];\n        photo2.frame = CGRectMake(0, 0, scroll.frame.size.width, scroll.frame.size.height);        \n    }\n\n\n    \/\/NSLog(@\"%f\",currPos);\n\n}\n\n- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{\n\n    UIImage *img = [photo1 getImage];\n    [photo1 setImage:[photo2 getImage]];\n    [self.scroll scrollRectToVisible:CGRectMake(self.scroll.frame.size.width, 0, self.scroll.frame.size.width, self.scroll.frame.size.height) animated:NO];\n    [photo2 setImage:img];\n\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8211; (void)scrollViewDidScroll:(UIScrollView *)scrollView{ float currPos = scroll.contentOffset.x; BOOL movingRight = ( currPos \/ scroll.frame.size.width ) &gt; 1 ? YES : NO ; if (movingRight) { NSLog(@&#8221;RIGHT&#8221;); [photo2 setImage:[UIImage imageNamed:@&#8221;22.jpg&#8221;]]; photo2.frame = CGRectMake(scroll.frame.size.width * 2, 0, scroll.frame.size.width, scroll.frame.size.height); }else{ NSLog(@&#8221;LEFT&#8221;); [photo2 setImage:[UIImage imageNamed:@&#8221;33.jpg&#8221;]]; photo2.frame = CGRectMake(0, 0, scroll.frame.size.width, scroll.frame.size.height); } \/\/NSLog(@&#8221;%f&#8221;,currPos); } &#8211; (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ UIImage [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5240","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5240"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5240\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}