<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: UIScrollView Paging Hack</title>
	<atom:link href="http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/</link>
	<description>this stuff is inedible</description>
	<lastBuildDate>Thu, 21 Jul 2011 18:46:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Theo</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-220</link>
		<dc:creator>Theo</dc:creator>
		<pubDate>Thu, 21 Jul 2011 18:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-220</guid>
		<description>If you change scrollViewDidEndDragging to:

- (void)scrollViewDidEndDragging:(UIScrollView *)_scrollView willDecelerate:(BOOL)decelerate {
if(!decelerate)
[self snapToPosition:_scrollView];
}

It seems to be a lot cleaner. That way the scrollViewDidDecelerate deals with when the scroll view is flicked and the scrollViewDidEndDragging deals with when the user doesn&#039;t flick.

Minor change to fix some unstable behaviour and conflict between the two methods that I thought might be useful to share. Really helpful otherwise. Thanks</description>
		<content:encoded><![CDATA[<p>If you change scrollViewDidEndDragging to:</p>
<p>- (void)scrollViewDidEndDragging:(UIScrollView *)_scrollView willDecelerate:(BOOL)decelerate {<br />
if(!decelerate)<br />
[self snapToPosition:_scrollView];<br />
}</p>
<p>It seems to be a lot cleaner. That way the scrollViewDidDecelerate deals with when the scroll view is flicked and the scrollViewDidEndDragging deals with when the user doesn&#8217;t flick.</p>
<p>Minor change to fix some unstable behaviour and conflict between the two methods that I thought might be useful to share. Really helpful otherwise. Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roland</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-219</link>
		<dc:creator>Roland</dc:creator>
		<pubDate>Mon, 04 Jul 2011 02:37:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-219</guid>
		<description>Hi,

Thanks for the post. I found it extremely useful. The current design implies that the width of the view is twice that of the images or whatever uiview. In my case, I needed to make the center view large, hence making the left and right placeholders are smaller. Here&#039;s the math that works: (monotouch C#)

float messageWidth = 550f, scrollerWidth = 1024f,
  initialOffset = (1024f-550f)/2f;

svMessagesView.Scrolled += delegate(object sender, EventArgs e) {
UIScrollView s = (UIScrollView)sender;
float offset = s.ContentOffset.X/(scrollerWidth/initialOffset/2f);
				CGAffineTransform transform = CGAffineTransform.MakeTranslation(offset, 0);
				messageContainer.Transform = transform;
};


initialOffset - are the widths of the slices on the sides.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for the post. I found it extremely useful. The current design implies that the width of the view is twice that of the images or whatever uiview. In my case, I needed to make the center view large, hence making the left and right placeholders are smaller. Here&#8217;s the math that works: (monotouch C#)</p>
<p>float messageWidth = 550f, scrollerWidth = 1024f,<br />
  initialOffset = (1024f-550f)/2f;</p>
<p>svMessagesView.Scrolled += delegate(object sender, EventArgs e) {<br />
UIScrollView s = (UIScrollView)sender;<br />
float offset = s.ContentOffset.X/(scrollerWidth/initialOffset/2f);<br />
				CGAffineTransform transform = CGAffineTransform.MakeTranslation(offset, 0);<br />
				messageContainer.Transform = transform;<br />
};</p>
<p>initialOffset &#8211; are the widths of the slices on the sides.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-215</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Sun, 06 Mar 2011 01:33:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-215</guid>
		<description>For me it works pretty well, but when the parameter &quot;decelerate&quot; is YES, it doesn&#039;t snap.
The parameter &quot;decelerate&quot; is YES when you drag fast then release your finger to let the scrollView scroll alone with the inertial scrolling.
How do I miss to make it work in any case?</description>
		<content:encoded><![CDATA[<p>For me it works pretty well, but when the parameter &#8220;decelerate&#8221; is YES, it doesn&#8217;t snap.<br />
The parameter &#8220;decelerate&#8221; is YES when you drag fast then release your finger to let the scrollView scroll alone with the inertial scrolling.<br />
How do I miss to make it work in any case?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praveen</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-214</link>
		<dc:creator>Praveen</dc:creator>
		<pubDate>Fri, 04 Mar 2011 11:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-214</guid>
		<description>Can you please tell me how to implement paging with 8 uiviews per page and also having the ui being more responsible.</description>
		<content:encoded><![CDATA[<p>Can you please tell me how to implement paging with 8 uiviews per page and also having the ui being more responsible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-205</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Thu, 09 Dec 2010 18:40:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-205</guid>
		<description>works flawlessly, with little modification you can set any paging size you want.

ludo: if u want your images in middle of screen u need to set right positions for images in contentView, considering your new paging size</description>
		<content:encoded><![CDATA[<p>works flawlessly, with little modification you can set any paging size you want.</p>
<p>ludo: if u want your images in middle of screen u need to set right positions for images in contentView, considering your new paging size</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ludo</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-154</link>
		<dc:creator>ludo</dc:creator>
		<pubDate>Thu, 22 Apr 2010 12:53:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-154</guid>
		<description>Don&#039;t need to approve my older post, its working now ^^

 RickiG I use your method and divide my scrollView into 3 parts, everything is working fine.
Now what I want is everytime an image appear in the middle of the scrollView and stop, I will display some information related to that Image into my view.

 But I don&#039;t know how to do that. How can I know which image is in the middle of the scrollView?


 Thanks</description>
		<content:encoded><![CDATA[<p>Don&#8217;t need to approve my older post, its working now ^^</p>
<p> RickiG I use your method and divide my scrollView into 3 parts, everything is working fine.<br />
Now what I want is everytime an image appear in the middle of the scrollView and stop, I will display some information related to that Image into my view.</p>
<p> But I don&#8217;t know how to do that. How can I know which image is in the middle of the scrollView?</p>
<p> Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ludo</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-153</link>
		<dc:creator>ludo</dc:creator>
		<pubDate>Thu, 22 Apr 2010 05:21:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-153</guid>
		<description>Hi,

 Maybe someone can help me here. I have a scrollView with some pictures inside (10 pictures)
and the screen can display 3 pictures. 
 I want to be able to divide my scrollView in 3 parts, so when I scroll it will scroll part by part.

 How can I do that? I can&#039;t make any of your code really work.

 Thank you</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p> Maybe someone can help me here. I have a scrollView with some pictures inside (10 pictures)<br />
and the screen can display 3 pictures.<br />
 I want to be able to divide my scrollView in 3 parts, so when I scroll it will scroll part by part.</p>
<p> How can I do that? I can&#8217;t make any of your code really work.</p>
<p> Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RickiG</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-145</link>
		<dc:creator>RickiG</dc:creator>
		<pubDate>Sat, 05 Dec 2009 21:11:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-145</guid>
		<description>Hi
I just found this post and had to do something similar. My issue was that I would like to divide an entire page into X smaller pages but still have the snap effect. This works really well:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)_scrollView {

	[self snapToPosition:_scrollView];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)_scrollView willDecelerate:(BOOL)decelerate {
	
	[self snapToPosition:_scrollView];
}	

- (void) snapToPosition:(UIScrollView *)_scrollView {

	CGFloat itemWidth = 80.0f;
	CGFloat position = [_scrollView contentOffset].x;
	CGFloat newPosition = 0.0f;	
	CGFloat offSet = position / itemWidth;
	NSUInteger target = (NSUInteger)(offSet + 0.5f);
	
	newPosition = target * itemWidth;

	[_scrollView setContentOffset:CGPointMake(newPosition, 0.0f) animated:YES];
}

itemWidth is the size of the smaller subviews I build the content of the scrollView from.</description>
		<content:encoded><![CDATA[<p>Hi<br />
I just found this post and had to do something similar. My issue was that I would like to divide an entire page into X smaller pages but still have the snap effect. This works really well:</p>
<p>- (void)scrollViewDidEndDecelerating:(UIScrollView *)_scrollView {</p>
<p>	[self snapToPosition:_scrollView];<br />
}<br />
- (void)scrollViewDidEndDragging:(UIScrollView *)_scrollView willDecelerate:(BOOL)decelerate {</p>
<p>	[self snapToPosition:_scrollView];<br />
}	</p>
<p>- (void) snapToPosition:(UIScrollView *)_scrollView {</p>
<p>	CGFloat itemWidth = 80.0f;<br />
	CGFloat position = [_scrollView contentOffset].x;<br />
	CGFloat newPosition = 0.0f;<br />
	CGFloat offSet = position / itemWidth;<br />
	NSUInteger target = (NSUInteger)(offSet + 0.5f);</p>
<p>	newPosition = target * itemWidth;</p>
<p>	[_scrollView setContentOffset:CGPointMake(newPosition, 0.0f) animated:YES];<br />
}</p>
<p>itemWidth is the size of the smaller subviews I build the content of the scrollView from.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: james</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-128</link>
		<dc:creator>james</dc:creator>
		<pubDate>Thu, 23 Jul 2009 18:44:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-128</guid>
		<description>jochen: When using a scrollview, you generally need to add some subviews that contain the actual content to be scrolled. Instead of putting those subviews in the scrollview directly, you should add them to what I&#039;m calling a container view, and then add the container view to the scrollview. If you&#039;re still confused, I&#039;d recommend checking out Apple&#039;s documentation on using scrollviews and make sure you&#039;re comfortable with their normal use before you try this technique.</description>
		<content:encoded><![CDATA[<p>jochen: When using a scrollview, you generally need to add some subviews that contain the actual content to be scrolled. Instead of putting those subviews in the scrollview directly, you should add them to what I&#8217;m calling a container view, and then add the container view to the scrollview. If you&#8217;re still confused, I&#8217;d recommend checking out Apple&#8217;s documentation on using scrollviews and make sure you&#8217;re comfortable with their normal use before you try this technique.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jochen</title>
		<link>http://www.inediblesoftware.com/blog/2009/04/05/uiscrollview-paging-hack/comment-page-1/#comment-127</link>
		<dc:creator>jochen</dc:creator>
		<pubDate>Thu, 23 Jul 2009 16:14:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.inediblesoftware.com/blog/?p=124#comment-127</guid>
		<description>can you please explain, how &quot;contentView&quot; in your example is created/used? It would be perfect, if you could provide a complete controller-code for this example...!

 best regards &amp; thanks</description>
		<content:encoded><![CDATA[<p>can you please explain, how &#8220;contentView&#8221; in your example is created/used? It would be perfect, if you could provide a complete controller-code for this example&#8230;!</p>
<p> best regards &amp; thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>

