<?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: iPhone Tip: Larger Hit Area for UIButton</title>
	<atom:link href="http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/</link>
	<description>fill the void</description>
	<lastBuildDate>Mon, 30 Jan 2012 09:42:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Marc</title>
		<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/comment-page-1/#comment-29879</link>
		<dc:creator>Marc</dc:creator>
		<pubDate>Mon, 09 Jan 2012 02:04:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.bdunagan.com/?p=672#comment-29879</guid>
		<description>There&#039;s a flaw in the maths here. You&#039;re subtracting the error margin from the origin, and then adding it to the width and height. This cancels out and means it won&#039;t recognise hits below the button or to the right.

The line:
    CGRect largerFrame = CGRectMake(0 - errorMargin, 0 - errorMargin, self.frame.size.width + errorMargin, self.frame.size.height + errorMargin);

Should be replaced by:
    CGRect largerFrame = CGRectMake(0 - errorMargin, 0 - errorMargin, self.frame.size.width + (errorMargin * 2), self.frame.size.height + (errorMargin * 2));</description>
		<content:encoded><![CDATA[<p>There&#8217;s a flaw in the maths here. You&#8217;re subtracting the error margin from the origin, and then adding it to the width and height. This cancels out and means it won&#8217;t recognise hits below the button or to the right.</p>
<p>The line:<br />
    CGRect largerFrame = CGRectMake(0 &#8211; errorMargin, 0 &#8211; errorMargin, self.frame.size.width + errorMargin, self.frame.size.height + errorMargin);</p>
<p>Should be replaced by:<br />
    CGRect largerFrame = CGRectMake(0 &#8211; errorMargin, 0 &#8211; errorMargin, self.frame.size.width + (errorMargin * 2), self.frame.size.height + (errorMargin * 2));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler</title>
		<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/comment-page-1/#comment-18350</link>
		<dc:creator>Tyler</dc:creator>
		<pubDate>Tue, 22 Nov 2011 18:58:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.bdunagan.com/?p=672#comment-18350</guid>
		<description>Actually, using pointInside works better, as your hitTest routine is overriding the isHidden flag. Your button still works even if it is hidden.


- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
  CGRect rect = CGRectInset([self bounds], -margin, -margin); 
  return CGRectContainsPoint(rect, point);
}</description>
		<content:encoded><![CDATA[<p>Actually, using pointInside works better, as your hitTest routine is overriding the isHidden flag. Your button still works even if it is hidden.</p>
<p>- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event<br />
{<br />
  CGRect rect = CGRectInset([self bounds], -margin, -margin);<br />
  return CGRectContainsPoint(rect, point);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler</title>
		<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/comment-page-1/#comment-18349</link>
		<dc:creator>Tyler</dc:creator>
		<pubDate>Tue, 22 Nov 2011 18:52:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.bdunagan.com/?p=672#comment-18349</guid>
		<description>Nevermind. It behaves in unexpected ways. Ah well.</description>
		<content:encoded><![CDATA[<p>Nevermind. It behaves in unexpected ways. Ah well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler</title>
		<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/comment-page-1/#comment-18347</link>
		<dc:creator>Tyler</dc:creator>
		<pubDate>Tue, 22 Nov 2011 18:36:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.bdunagan.com/?p=672#comment-18347</guid>
		<description>Instead of using CGRectMake, you could use CGRectInset([self frame],-errorMargin,-errorMargin).

It&#039;s a bit cleaner.</description>
		<content:encoded><![CDATA[<p>Instead of using CGRectMake, you could use CGRectInset([self frame],-errorMargin,-errorMargin).</p>
<p>It&#8217;s a bit cleaner.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kb1ooo</title>
		<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/comment-page-1/#comment-8857</link>
		<dc:creator>kb1ooo</dc:creator>
		<pubDate>Tue, 08 Feb 2011 21:25:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.bdunagan.com/?p=672#comment-8857</guid>
		<description>@bdunagan one correction. +buttonWithType (in addition to using -initWithFrame) will return the proper subclass, but again *only* for UIButtonTypeCustom.</description>
		<content:encoded><![CDATA[<p>@bdunagan one correction. +buttonWithType (in addition to using -initWithFrame) will return the proper subclass, but again *only* for UIButtonTypeCustom.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kb1ooo</title>
		<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/comment-page-1/#comment-8856</link>
		<dc:creator>kb1ooo</dc:creator>
		<pubDate>Tue, 08 Feb 2011 21:01:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.bdunagan.com/?p=672#comment-8856</guid>
		<description>@bdunagan what do you mean &quot;it just works&quot;. You didn&#039;t show how you created an instance of your subclass? If you are *not* using +buttonWithType then you are stuck at only being able to create UIButtonTypeCustom type buttons. What do you do for the other types? It&#039;s worse than @Michelle suggested because +buttonWithType returns an instance of one of many different private classes depending on the type.</description>
		<content:encoded><![CDATA[<p>@bdunagan what do you mean &#8220;it just works&#8221;. You didn&#8217;t show how you created an instance of your subclass? If you are *not* using +buttonWithType then you are stuck at only being able to create UIButtonTypeCustom type buttons. What do you do for the other types? It&#8217;s worse than @Michelle suggested because +buttonWithType returns an instance of one of many different private classes depending on the type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bdunagan</title>
		<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/comment-page-1/#comment-5957</link>
		<dc:creator>bdunagan</dc:creator>
		<pubDate>Thu, 19 Aug 2010 02:00:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.bdunagan.com/?p=672#comment-5957</guid>
		<description>@Michelle No need to worry about buttonWithType. If you simply subclass UIButton and override hitTest, it just works. I updated the post with code showing how.</description>
		<content:encoded><![CDATA[<p>@Michelle No need to worry about buttonWithType. If you simply subclass UIButton and override hitTest, it just works. I updated the post with code showing how.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michelle</title>
		<link>http://www.bdunagan.com/2010/03/01/iphone-tip-larger-hit-area-for-uibutton/comment-page-1/#comment-4743</link>
		<dc:creator>Michelle</dc:creator>
		<pubDate>Thu, 01 Apr 2010 19:45:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.bdunagan.com/?p=672#comment-4743</guid>
		<description>Can you say a bit about how to &quot;programmatically grow button’s hit area via UIView::hitTest&quot;.  I&#039;m not clear how you can do that for a UIButton, as buttonWithType always returns a UIButton rather than a subclass.</description>
		<content:encoded><![CDATA[<p>Can you say a bit about how to &#8220;programmatically grow button’s hit area via UIView::hitTest&#8221;.  I&#8217;m not clear how you can do that for a UIButton, as buttonWithType always returns a UIButton rather than a subclass.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

