Detail Disclosure Button and Segues - iphone

I'm using a UITableViewController that performs an action sheet upon click, which works great. I'd like to tie the Detail Disclosure to a segue. I created a segue from the cell to the next table, and added the following code:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"GroupToGroupMembers" sender:self];
}
Works great when I tap the Detail Disclosure.
Problem is, tapping on the cell now causes both the action sheet AND the segue to fire off, which I would expect.
Anyone figure out how to fire off a segue off of a detail disclosure only?

You probably have the "GroupToGroupMembers" segue hooked up to your UITableViewCell. When you do this, the segue is automatically performed when the cell is selected. This happening in addition to your regular event handling which is showing the action sheet.
Hook your segue up to your UITableViewController instead. This allows you to define your segue so that it may be performed in response to the DetailDisclosure being tapped while, at the same time, preventing the segue from being automatically performed when a cell is selected.

Related

UITableViewCell segue created in Interface Builder will not fire

Currently, I have a basic UI set up in Interface Builder that features a UITableViewController, with a seque leading from the prototype cell to a detail view. My code dequeues the cell with the identifier I have set in Interface Builder, but when testing the app, a tap on the cell does nothing but turn it blue.
I want the segue to push the detail view on to my navigation controller's stack, but the segue simply won't happen. Why could this be?
Assuming you are working on storyboards (segues, etc.) there is a bug in the auto layout scheme of iOS. Hence the segue is not fired. However, you can simply give the segue and identifier in attributes inspector of the segue, and programmatically from your class you can use
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
in this method you can fire the segue in the following manner.
[self performSegueWithIdentifier:(NSString*) target:(id)];
Let me know if this helps you.
(Make sure your delegates and datasources are all set up correctly).

Segue not performing

I'm currently facing something I find rather strange.
In my storyboard, there is a TableViewController filled with static cells.
I would like to perform a simple segue (a push to another view controller) when I select one of the rows.
So I "ControlDrag" from the concerned table cell to the sibling controller, but when tap one the cell, nothing happens. Next to that, I did try assigning the segue triggering to the accessory view of the cell (a disclosure button). And in that case, the segue is effectively triggered.
So here is my question : Should I use the "programmatic way" to handle the tap on the cell (tableview delegate methods and manual segue performing), or is there something I'm missing in the interface builder? And btw how could we explain the behavior difference with the accessory button view ?
Here is two screenshot
Cell selection that should trigger segue
And, the accessory action which performs the segue
I finally found what the problem was. I had a gesture recognizer attached to the view controller, and it was catching the tap event on the cell.

storyboard segue from a tablecell an its Detail Disclosure Button

I want to segue from a tablecell to two different viewcontrollers
if clicked in the cell or clicked on the cells Detail Disclosure Button.
If I ctrl-drag the second segue, the first is deleted.
What am I doing wrong?
Tnx
Mica
I don't think you can link a specific detail disclosure button w/ a segue. My storyboards are extremely programatic b/c I use alot of custom CGRect etc..
so I tend to use something like this:
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"ViewControllerIdentifer" sender:self];
}
for reference this is an extremely good example project on storyboards and tableviews. there's a link to the project at the bottom also.
http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2

Weird problem with iPhone UITableView cell not un-highlighting after clicking

I have an app I am working on, that has a table view with a few cells, and when you hit a cell, the nav controller pushes a new view. Pretty simple stuff. The problem is that when I hit on a row, the whole row highlights blue, and then remains blue all while the view is being presented by the controller, and then if I hit back to go back to the table view, the row is just still completely highlighted Even though I'm not pressing it or anything.
I have made a few apps with the table view before, and have never seen this behavior before, so I am at a loss as to what is going on. Is there some setting that I have set wrong somewhere?
Thanks
You need to deselect cell manually (probably in tableView:didSelectRowAtIndexPath: method):
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// Your code
...
}
If your view controller is a subclass of UITableViewController, it will automatically deselect the row after you hit the back button. If you don't subclass UITableViewController, you need to call deselectRowAtIndexPath:animated: when you want it deselected.

UITableView cells do not stay selected when pushing a view

I have a UITableView on a view. This UITableView has cells which are made up of a checkbox custom control, a label and a disclosure accessory. When I select a row in the tableview it selects correctly (blue highlight shows 100% correctly).
I then created a didSelectRowAtIndexPath delegate to push a detail view controller onto the navigation stack using the following code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MyDetailsViewController *detailsViewController = [[MyDetailsViewController alloc] initWithNibName:#"MyDetailsView" bundle:nil];
[[self navigationController] pushViewController:detailsViewController animated:YES];
[detailsViewController release];
}
This works - in so far as that it pushes the view controller onto the navigation stack and presents the view. The problem I'm having is that the animation is really "flickery" and the row that was selected doesn't even get highlighted before the animation starts.
I've done this before (but never with custom cells) and I know that the procedure should be as follows: row highlights, detail view animates in, (edit details), detail view animates out, row gets deselected.
I'm not sure why my row automatically gets deselected (or de-highlighted) when I select it and why the animation is flickery.
Has anyone had this before?
Ugh, I so hate it when I find the answer to my own question about a minute after posting it. The problem was that I was doing all kinds of things in viewWillDisappear that was modifying my table data. ****grin****