Did you able to use a separate initial view except from the one when Tabitem selected?
I am looking for such an solution.
settings tabBarController.tabBar.selectedItem = nil;
throw an error,
'Directly modifying a tab bar managed by a tab bar controller is not allowed.'
Plz add the TabeleView Delegate and Table View Data source in the header file and implement the standard protocol method , in the didSelect method add code to load ur Detail View. Plz refer iPhone samples TableViewSuit .
Quote:
Originally Posted by ujagtap
Hi everybody,
I have developed following application,
1. Took UITabBarController and UINavigationController in first tab.
2. In first navigation controller i took UISegmentedControl.
3. On segment selection i am changing views.
4. On first segment i am showing UITableView and on second segment i am showing UIImageView.
5. If i select any row from UITableView i want to display details for that row, by calling another ViewController.
But on selection of table cell it is not going ahead.
Please see attached sample code.
In DetailViewController i am calling showDetails() and in that function i am calling pushViewController for SecondTableView but it is not working. Please help.
I have been searching for a way to combine all three for almost 2 weeks now and have gotten nowhere. I see that you had a solution to the problem. Is it possible to let me know how to do it. I have been able to get all 3 together only to lose the ability to select the rows. Please help.
Ok guys, the easiest way to be honest, and u wont have any troubles anymore, is to Follow O'reilly youtube channel..
atm, im at this YouTube - Building an iPhone App Part II
But if u look in description of that video, and starts the previous tutorial of that, it has all 3 u guys requested in 1, and works perfectly
Good luck
This is a great thread. Thanks to all for participating. What is the proper location for setting the title and image for a Table View Controller that is part of a Nav Controller that is part of a Tab Bar Controller?
I set the tabBarItem.title and tabBarItem.image in the init method of Custom View Controller and that works just fine. But when I override init for TableViewController and set title and image for tabBarItem for the Nav Controller-TableViewController tabs the corresponding label and image do not appear in the tab. I am not sure what is the proper place to set the tab bar item for this scenario. I am doing this programmatically. Thank you.
Having a Login page before the NavBar-TableView-TabBar nib
Quote:
Originally Posted by DevTeamOfOne
Code:
@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
MyTableViewController *myTableViewController;
MySecondTableViewController *mySecondTableViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UITabBarController *tabBarController;
@property (nonatomic, retain) MyTableViewController *myTableViewController;
@property (nonatomic, retain) MySecondTableViewController *mySecondTableViewController;
@end
@implementation AppDelegate
@synthesize window, myTableViewController, mySecondTableViewController, tabBarController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
tabBarController = [[UITabBarController alloc] init]; // creates your tab bar so you can add everything else to it
myTableViewController = [[MyTableViewController alloc] init]; // creates your table view - this should be a UIViewController with a table view in it, or UITableViewController
UINavigationController *tableNavController = [[[UINavigationController alloc] initWithRootViewController:myTableViewController] autorelease];
[myTableViewController release]; // creates your table view's navigation controller, then adds the view controller you made. Note I then let go of the view controller as the navigation controller now holds onto it for me. This saves memory.
mySecondTableViewController = [[MySecondTableViewController alloc] init];
UINavigationController *table2NavController = [[[UINavigationController alloc] initWithRootViewController:mySecondTableViewController] autorelease];
[mySecondTableViewController release]; // does exactly the same as the first round, but for your second tab at the bottom of the bar.
tabBarController.viewControllers = [NSArray arrayWithObjects:tableNavController, table2NavController, nil]; add both of your navigation controllers to the tab bar. You can put as many controllers on as you like, but they will turn into the more button like in the iPod program.
[window addSubview:tabBarController.view]; // adds the tab bar's view property to the window
[window makeKeyAndVisible]; // makes the window visible
}
- (void)dealloc {
[tabBarController release];
[window release];
[super dealloc];
} // lets go of everything else, thats so your program doesn't create any leaks of memory.
@end
I just typed up this quick App Delegate to show you how to do it. Yes, you do have rights to use whatever part of it you wish, and yes, you can ask any questions you like.
Please do note:
a ) I release the table views because they have been retained by the Navigation Controllers. Thus, I have doubled up and am taking double the memory. Once you have a nav controller holding your view, drop it. This saves memory. These nav controllers are set to drop automattically with their autorelease so there is no leak issue.
b ) if you need to add only one item to your tabBar for some strange reason, or just to test, change "arrayWithObjects: blah, blah2, nil" to "arrayWithObject: blah" and drop the nil.
Does this help you???
Hi Dev & Others,
If I have to first display an Login view and then show the NavigationController-TableView-TabBarController view to the user, how can I achieve it. The above code works without showing the Login page, but I want to have the login page and validate before showing the Tab bar.
I tried creating an LoginViewController and call it from the MainWindow.xib. From the login view's button clicked action, I pushed the Tabbar view controller. However, I couldn't succeed on it.
I tried the suggested steps (used the IB, instead of direct coding) and created an application with an login view and navcontroller-tableview-tabbarcontroller page.
The application closes (without any error displayed in the console window) abruptly, on the following sequence.
- run the app
- click the login button (no entries required)
- in the "Seller" tab bar page, click on any one of the table row. It would navigate to the "Vehicle Info" page.
- click on the back navigation button "Seller Vehicles"
- Application crashes
I spent days analyzing the issue but couldn't succeed. If someone can run the app, analyze the code and let me know what's wrong, it would be great.
I tried the suggested steps (used the IB, instead of direct coding) and created an application with an login view and navcontroller-tableview-tabbarcontroller page.
The application closes (without any error displayed in the console window) abruptly, on the following sequence.
- run the app
- click the login button (no entries required)
- in the "Seller" tab bar page, click on any one of the table row. It would navigate to the "Vehicle Info" page.
- click on the back navigation button "Seller Vehicles"
- Application crashes
I spent days analyzing the issue but couldn't succeed. If someone can run the app, analyze the code and let me know what's wrong, it would be great.
Thanks
Ela
This problem is now solved. It was something to do with memory management, which I had handled wrongly.
Nevermind, i did it using the appDelegate...i just dont understand why Apple says not to use singletons like the UIApplication sharedApplication if sometimes its the only way to get things to work...or is there any other way to make this work?
How do u program the tableviewcontroller to push the next VC from the didselectrowatindexpath since the navcontroller is declared in the app delegate so u can't write self.navcontroller push.....?
Quote:
Originally Posted by BostonMerlin
Thanks Dev. I was able to get that code running with one tab showing a UINavigationController and a table full of data and the other tab showing a UIViewController with a page of labels and buttons. Very nice.. thank you!
I am hitting a wall though. Using your code i've tried any number of ways to add content below the nav bar but above the tableview. I'm trying to get the following look for this app....
Pseudo Description:
- App should have a tabbar at the bottom with two tabs
- the first tab shows a navigationcontroller up top, label and image below it followed by a tableview.
- the second tab shows labels and images.
For whatever reason the tabbar is the big pain! I know this isnt rocket science.. it's just not clicking. I can perform these tasks w/out the tab bar but throw that into the mix and i'm getting nothing but a white page on that first tab.
I am very new into iphone application development,
I am trying to create an application
1- Loging view
2 after login go to a navigation based application with tableview and tabbar at bottom.
3- when i pushview at table row then goto again to a tableview and again select a row then go to a detail view , that detail view have diffrent tabbar . and when i click those tab show diffrent view with same navigation bar .
creating a tabbar and navigation bar programmatically
Quote:
Originally Posted by DevTeamOfOne
Code:
@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
MyTableViewController *myTableViewController;
MySecondTableViewController *mySecondTableViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UITabBarController *tabBarController;
@property (nonatomic, retain) MyTableViewController *myTableViewController;
@property (nonatomic, retain) MySecondTableViewController *mySecondTableViewController;
@end
@implementation AppDelegate
@synthesize window, myTableViewController, mySecondTableViewController, tabBarController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
tabBarController = [[UITabBarController alloc] init]; // creates your tab bar so you can add everything else to it
myTableViewController = [[MyTableViewController alloc] init]; // creates your table view - this should be a UIViewController with a table view in it, or UITableViewController
UINavigationController *tableNavController = [[[UINavigationController alloc] initWithRootViewController:myTableViewController] autorelease];
[myTableViewController release]; // creates your table view's navigation controller, then adds the view controller you made. Note I then let go of the view controller as the navigation controller now holds onto it for me. This saves memory.
mySecondTableViewController = [[MySecondTableViewController alloc] init];
UINavigationController *table2NavController = [[[UINavigationController alloc] initWithRootViewController:mySecondTableViewController] autorelease];
[mySecondTableViewController release]; // does exactly the same as the first round, but for your second tab at the bottom of the bar.
tabBarController.viewControllers = [NSArray arrayWithObjects:tableNavController, table2NavController, nil]; add both of your navigation controllers to the tab bar. You can put as many controllers on as you like, but they will turn into the more button like in the iPod program.
[window addSubview:tabBarController.view]; // adds the tab bar's view property to the window
[window makeKeyAndVisible]; // makes the window visible
}
- (void)dealloc {
[tabBarController release];
[window release];
[super dealloc];
} // lets go of everything else, thats so your program doesn't create any leaks of memory.
@end
I just typed up this quick App Delegate to show you how to do it. Yes, you do have rights to use whatever part of it you wish, and yes, you can ask any questions you like.
Please do note:
a ) I release the table views because they have been retained by the Navigation Controllers. Thus, I have doubled up and am taking double the memory. Once you have a nav controller holding your view, drop it. This saves memory. These nav controllers are set to drop automattically with their autorelease so there is no leak issue.
b ) if you need to add only one item to your tabBar for some strange reason, or just to test, change "arrayWithObjects: blah, blah2, nil" to "arrayWithObject: blah" and drop the nil.
Does this help you???
I am a beginner i want the full code to implement the things which you have shared . please help me out.