app with tab bar and navigation bars - iphone

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

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

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

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.

Changing UITabBar during Navigation in iOS

When my app launches, it presents a navigation view with a tableview and a tabbar on the bottom.
Something like this:
TabBar --> UINav1, UINav2, UINav3, UINav4
Each UINav contains a ViewController that is eventually displayed.
What I want to be able to do is to change the UITabBar if the user moves from the ListView (Main screen) to the detail view.
I don't have to swap out the whole tabbar atleast change/remove the buttons.
However, if I use the above model (setting TabBarController as the root controller) then it seems it's pretty much stuck and immutable in the course of the navigation. The best I can do is just hide it in certain views.
Been banging my head for like a day trying to figure this out.
Thanks!
You could use
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
in your UITabBarController to set the tabBar whatever viewController you wish
EDIT: You might wan't to look at this question wish seems to be quite similar iPhone, how I hide a tab bar button?
It is not very common but you can present a new tab bar controller along with its associated view(s) modally.
Assuming your listView is a UITableViewController, you can push the new tab bar controller in your didSelectRowAtIndexpath method.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// ...
[self.tabBarController presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated]
PS: I would be very careful with how you structure your UI in this case as it can get quite confusing for the user).
I hope it helps.
Rog
Upon further research, decided that this was not feasible to do.

iphone uitableview to another view

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.