UITableViewCell segue created in Interface Builder will not fire - iphone

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).

Related

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

Detail Disclosure Button and Segues

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.

How would I make a tableview lead to a page which had another tableview?

I want to make a tableview; when you press a cell it takes you to another tableview. If you press a cell on the second table, it takes you to another view. Then, you could go back if you want or whatever. How would I do this? I can make a tableview lead to a new view already, but the real question is how to make another tableview and lead to another view.
I'm not sure if I follow..
Anyhow, I recommend you create a UINavigationController and set the rootViewController to your tableView's controller view property, when a cell is tapped in your tableview you should implement:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
where you would create an instance of another view controller that holds your desired "different" tableview obviously and push it to the navigation controller.
I recommend you take a look at the view controllers programming guide as well as tableviews. It isn't that complex.
The key idea is to know that this behavior you want is basically how the navigation controller works by pushing and popping views.
If you implement it this way (which is what you should be doing) you get lots of functionality for free, such as the behavior when tapping on the "back" button.
Hope it helps.
Do you want to use both tables in the same view controller or do you want to use navigation controller to navigate to the next table view? If you want to use both the tables in the same view controller then differentiate them by tag value.

app with tab bar and navigation bars

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];
}

setting target for disclosure button on subclassed UITableViewCell

I've created a subclass of UITableViewCell to create some custom appearance and UI functionality ('swipe to reveal delete button').
Some of the cells are disclosure/detail disclosure type, and have a UIButtonTypeDetailDisclosure etc added manually. I cannot use the table view controllers' UITableViewCellAccessory for row at index path method.
The question is, how do I set the target of these manually added buttons so that they correctly send the didSelectRowAtIndexPath to their table view controller?
There is no direct way of setting an action the accessory disclosure button. Though you can do this with delegate method
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
See if that works.