<?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: Custom button in UITableViewCell &#8211; indexPath</title>
	<atom:link href="http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/</link>
	<description>iPhone Game Development - Web Development</description>
	<lastBuildDate>Sat, 04 Feb 2012 20:13:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: ajcolon</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-4/#comment-4287</link>
		<dc:creator>ajcolon</dc:creator>
		<pubDate>Mon, 25 Oct 2010 15:12:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-4287</guid>
		<description>Im kind of new to this and would really like to implement this in my project, but Im missing something. If I have in the CustomCell class two buttons how does the action gets connected to the TableViewController? and how would I know which of both buttons was pressed?</description>
		<content:encoded><![CDATA[<p>Im kind of new to this and would really like to implement this in my project, but Im missing something. If I have in the CustomCell class two buttons how does the action gets connected to the TableViewController? and how would I know which of both buttons was pressed?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: snowflake</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-4/#comment-4050</link>
		<dc:creator>snowflake</dc:creator>
		<pubDate>Wed, 15 Sep 2010 14:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-4050</guid>
		<description>I am new to  iphone and I am trying to add the button in uitable with the following code but when I press the button I get GDB:Program received signal:&quot;SIGBART&quot;

***************************************
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//more stuf here
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
	[myButton setBackgroundColor:[UIColor greenColor]];
	myButton.titleLabel.text = @&quot;Add&quot;;
	[myButton addTarget:self action:@selector(butonMethod:)   
	   forControlEvents:UIControlEventTouchUpInside];
	[cell.contentView addSubview:myButton];
}
*****************************************
this is the method
- (void)buttonMethod:(UIButton *)sender {
	
	// method for finding what button was pressed
	
	NSIndexPath *indexPath = [theTableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]];
	
	NSInteger section = indexPath.section;
	NSInteger row = indexPath.row;
	
	NSLog(@&quot;Button is in section %d and row %d&quot;, section, row);
	
}
 in my .h files

UIButton *buttonMethod;
- (void)buttonMethod:(UIButton *)sender;

please could some one tell me what is wrong thanks in advance</description>
		<content:encoded><![CDATA[<p>I am new to  iphone and I am trying to add the button in uitable with the following code but when I press the button I get GDB:Program received signal:&#8221;SIGBART&#8221;</p>
<p>***************************************<br />
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {<br />
//more stuf here<br />
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeContactAdd];<br />
	[myButton setBackgroundColor:[UIColor greenColor]];<br />
	myButton.titleLabel.text = @&#8221;Add&#8221;;<br />
	[myButton addTarget:self action:@selector(butonMethod:)<br />
	   forControlEvents:UIControlEventTouchUpInside];<br />
	[cell.contentView addSubview:myButton];<br />
}<br />
*****************************************<br />
this is the method<br />
- (void)buttonMethod:(UIButton *)sender {</p>
<p>	// method for finding what button was pressed</p>
<p>	NSIndexPath *indexPath = [theTableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]];</p>
<p>	NSInteger section = indexPath.section;<br />
	NSInteger row = indexPath.row;</p>
<p>	NSLog(@&#8221;Button is in section %d and row %d&#8221;, section, row);</p>
<p>}<br />
 in my .h files</p>
<p>UIButton *buttonMethod;<br />
- (void)buttonMethod:(UIButton *)sender;</p>
<p>please could some one tell me what is wrong thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Kimber</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-4/#comment-3984</link>
		<dc:creator>Richard Kimber</dc:creator>
		<pubDate>Tue, 07 Sep 2010 11:43:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-3984</guid>
		<description>Hi,

I&#039;ve adjusted the code to work out the UITableView as well, useful for multiple table views.

	UITableViewCell *currentCell = (UITableViewCell *)[[sender superview] superview];
	UITableView *currentTable = (UITableView *)[currentCell superview];
	NSIndexPath *indexPath = [currentTable indexPathForCell:currentCell];

Rich</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;ve adjusted the code to work out the UITableView as well, useful for multiple table views.</p>
<p>	UITableViewCell *currentCell = (UITableViewCell *)[[sender superview] superview];<br />
	UITableView *currentTable = (UITableView *)[currentCell superview];<br />
	NSIndexPath *indexPath = [currentTable indexPathForCell:currentCell];</p>
<p>Rich</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Richard Kimber</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-3/#comment-3983</link>
		<dc:creator>Richard Kimber</dc:creator>
		<pubDate>Tue, 07 Sep 2010 11:43:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-3983</guid>
		<description>Hi,

I&#039;ve adjusted the code to work out the UITableView as well, useful for multiple table views.

	UITableViewCell *currentCell = (UITableViewCell *)[[sender superview] superview];
	UITableView *currentTable = (UITableView *)[currentCell superview];
	NSIndexPath *indexPath = [currentTable indexPathForCell:currentCell];

Rich</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;ve adjusted the code to work out the UITableView as well, useful for multiple table views.</p>
<p>	UITableViewCell *currentCell = (UITableViewCell *)[[sender superview] superview];<br />
	UITableView *currentTable = (UITableView *)[currentCell superview];<br />
	NSIndexPath *indexPath = [currentTable indexPathForCell:currentCell];</p>
<p>Rich</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-3/#comment-3933</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 18 Aug 2010 17:58:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-3933</guid>
		<description>Man this code is definitely a nugget of gold!

Exactly what I needed. Thanks!!</description>
		<content:encoded><![CDATA[<p>Man this code is definitely a nugget of gold!</p>
<p>Exactly what I needed. Thanks!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob P</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-3/#comment-3333</link>
		<dc:creator>Rob P</dc:creator>
		<pubDate>Sat, 08 May 2010 15:30:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-3333</guid>
		<description>You rock man... super simple and easy to implement!

@Rob above, make sure it is within a uitableviewcontroller and you have setup the dataSource and delegate.  The code should be something like this within the parent view controller for that table:

- (void)buttonMethod:(UIButton *)sender {

// method for finding what button was pressed

	NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]];
	
	NSInteger section = indexPath.section;
	NSInteger row = indexPath.row;
	
	NSLog(@&quot;Button is in section %d and row %d&quot;, section, row);
	
}

and then put this in the .h file

UIButton *buttonMethod;

and 

- (void)buttonMethod:(UIButton *)sender;</description>
		<content:encoded><![CDATA[<p>You rock man&#8230; super simple and easy to implement!</p>
<p>@Rob above, make sure it is within a uitableviewcontroller and you have setup the dataSource and delegate.  The code should be something like this within the parent view controller for that table:</p>
<p>- (void)buttonMethod:(UIButton *)sender {</p>
<p>// method for finding what button was pressed</p>
<p>	NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]];</p>
<p>	NSInteger section = indexPath.section;<br />
	NSInteger row = indexPath.row;</p>
<p>	NSLog(@&#8221;Button is in section %d and row %d&#8221;, section, row);</p>
<p>}</p>
<p>and then put this in the .h file</p>
<p>UIButton *buttonMethod;</p>
<p>and </p>
<p>- (void)buttonMethod:(UIButton *)sender;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-3/#comment-3166</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Tue, 20 Apr 2010 15:35:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-3166</guid>
		<description>Hi Mike,
Thanks for the awesome tip!
I&#039;m trying to do the same thing, but I&#039;m getting an error in my TableViewCell subclass for the &quot;NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]];&quot; saying that the &quot;Request for member &#039;tableView&#039; in something that is not a structure or union&quot;. 
Do I need to pass that down somehow?
Thanks again for getting me one step closer!!</description>
		<content:encoded><![CDATA[<p>Hi Mike,<br />
Thanks for the awesome tip!<br />
I&#8217;m trying to do the same thing, but I&#8217;m getting an error in my TableViewCell subclass for the &#8220;NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]];&#8221; saying that the &#8220;Request for member &#8216;tableView&#8217; in something that is not a structure or union&#8221;.<br />
Do I need to pass that down somehow?<br />
Thanks again for getting me one step closer!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andiih</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-3/#comment-3007</link>
		<dc:creator>Andiih</dc:creator>
		<pubDate>Thu, 01 Apr 2010 17:28:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-3007</guid>
		<description>Yep. still useful!</description>
		<content:encoded><![CDATA[<p>Yep. still useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-3/#comment-2756</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Wed, 24 Feb 2010 11:38:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-2756</guid>
		<description>Thanks Giova

Mike</description>
		<content:encoded><![CDATA[<p>Thanks Giova</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giova</title>
		<link>http://www.71squared.com/2008/12/custom-button-in-uitableviewcell-indexpath/comment-page-3/#comment-2755</link>
		<dc:creator>Giova</dc:creator>
		<pubDate>Wed, 24 Feb 2010 10:56:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.71squared.co.uk/?p=106#comment-2755</guid>
		<description>GREAAAAT!!!!!!! Thank you man, Awesome and super useful post, really, I&#039;ve browsed so many blogs before findind you!!

Thanks</description>
		<content:encoded><![CDATA[<p>GREAAAAT!!!!!!! Thank you man, Awesome and super useful post, really, I&#8217;ve browsed so many blogs before findind you!!</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>

