I am using XCode's Navigation-based Application template to create an app that centers around an UITableView.
When the user selects a row in the UITableView I want to display a button inside of that selected cell. I want to display this button only in the cell selected and not in any other cells. The same goes if the user selects a different cell afterwards.
How do I go about doing this? Is it possible?
Did you check developer.apple.com for the documentation of the UITableViewController and the UIButton ?
This should be possible using something like the following:
EDIT: you will of course need to remove the button from the contentView when you select a new cell, so you will need a little logic for that. Subclassing may be an easier solution, but this is the route you will need to take if you don't want to sublass. For example, you would want to declare the following in your header.
Then you will want to incorporate that into the above (which I'll change to put it in);
THIS IS A SIMPLE SOLUTION!
Create your button in somewhere like the viewDidLoad function (make sure it is declared in the .h file so you can refer to it from anywhere)
in the -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
add the following:
Subclass UITableViewCell and add the button to it.
Then override setSelected like so: