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
Related
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).
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.
Hi all,
this is a typical layout of one of apps. Now what I want on clicking of row of one of the view controllers(table view), I want to change the index of of the tab. Lets say I am in 3rd view, I want to move to the 1st view.
I tried with navigation controller's didShowViewController delegate method. Seems its not working. Could you please suggest any other way to do this?
Thanks.
Just use the below code in didSelectRowAtIndexPath method of UITableView, then you just need to set the SelectedIndex for Tabbar.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
[self.tabBarController setSelectedIndex:indexPath.row];
}
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.
in my program I need a tableview and, when you click onto a row, the view scroll left and show the details (like the mail for example...)
how can I do this??
I explain... it's an automatic thing or I need to manage by hand the animation of the view??
thanks in advance
I use UINavigationControllers to achieve this effect of the detail animating left when you click on the row. So you need a UINavigation controller above the UIViewController or UITableView Controller that controls your table.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
...my code
[self.navigationController pushViewController:myViewController animated:YES];
}
Your case is exactly what UINavigationController class is for - it will handle your controllers hierarchy and will do animated transition for you as well. To learn how to use it you can have a look at Apple's NavBar sample.