iOS: UINavigationBar title doesn't appear - ios5

I am not sure what's going wrong with my UINavigationBar title things. I am not able to get it working after trying all possible things. The navigation bar appears but title is missing!! Here is my simple code,
self.marketsListViewController = [[MarketsListViewController alloc] initWithNibName:#"MarketsListViewController" bundle:nil];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:self.marketsListViewController];
nvc.navigationBar.barStyle = UIBarStyleBlack;
[self.marketsListView addSubview:nvc.view];
[self addChildViewController:nvc];
[nvc didMoveToParentViewController:self];
In MarketsListViewController's didViewLoad, I have tried all of following and none of them worked!!! Could someone please help me to understand what's going on? Thanks.
self.title = #"MyTitle";
self.navigationItem.title = #"MyTitle";
self.navigationController.navigationItem.title = #"MyTitle";

There seem to be some changes in UINavigationController from iOS6.
https://stackoverflow.com/a/13205842/1171003
When I wrote code like this, the title was not shown at all.
UITabBarController *tb = [[UITabBarController alloc] init];
tb.viewControllers = [NSArray arrayWithObjects:
[[ViewController1 alloc] init],
[[ViewController2 alloc] init],
nil];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:tb];
However, after I added this line, it appeared.
tb.title = #"Title";

Related

How to Customise my Tabbar controller icons (background images)?

I have an iphone application in which i wanted to show my own images as the tabbar icons.but now only the default greyone is coming.i need to change it to the my own images?.I went through lot of links,but nothing seems to be very clear.that can anybody know how to achieve this?
Please download source code from here and change images according to your requirement.
You can set image on tabBarItem like this :-
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate = self;
ViewController *viewObject= [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
UINavigationController *navView = [[UINavigationController alloc] initWithRootViewController: viewObject];
UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:#"Tutorial" image:[UIImage imageNamed:#"kb-emoji-U+E031.png"] tag:1];
navView.tabBarItem = tabBarItem;
tabBarController.viewControllers = [NSArray arrayWithObjects:navView,nil];
self.window.rootViewController = tabBarController;
Also see this link - click me

Custom UITabBar that expand on selection

I am trying to achieve the below attach image on the UITabbar.
http://i.imgur.com/7Tukx.png
It's pretty straight forward, on selection the tab expand with a label to display text and on selection on another tab, the selected tab will collapse.
I am not really sure how to do this with the UItabbar.
I will appreciate if anyone could point me in the right direction.
for the custom tab you use this method on appdelegate class
this method create two tab bar item.
and you set your image..
-(void)SetTabs
{
tabBarController = [[UITabBarController alloc]init];
NSMutableArray *localControllerArray = [[NSMutableArray alloc]initWithCapacity:2];
UIImage *image = [UIImage imageNamed:#"home.png"];
GreetingCardsViewController *GreetingCardsView = [[[GreetingCardsViewController alloc] initWithNibName:#"GreetingCardsViewController" bundle:nil] autorelease];
UITabBarItem *item = [[UITabBarItem alloc]initWithTitle:#"Home" image:image tag:0];
UINavigationController *GreetingCardsViewNavigationController = [[UINavigationController alloc]initWithRootViewController:GreetingCardsView];
GreetingCardsView.tabBarItem = item;
[localControllerArray addObject:GreetingCardsViewNavigationController];
UIImage *image1 = [UIImage imageNamed:#"heart1.png"];
Cards *CardView = [[[Cards alloc] initWithNibName:#"Cards" bundle:nil] autorelease];
UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:#"Cards" image:image1 tag:1];
UINavigationController *CardNavigationController = [[UINavigationController alloc]initWithRootViewController:CardView];
CardNavigationController.tabBarItem = item1;
[localControllerArray addObject:CardNavigationController];
[tabBarController setViewControllers:localControllerArray];
[_window addSubview:tabBarController.view];
[localControllerArray release];
}
I'm not entirely sure what you're after, however I think this may be relevant to you. You could use the basic concept and tweak it to what you need.

Complex multiview iphone ios

i need to implement a multiview app really complex to me and i need some advice. The multiview app is something like:
First view: Normal UIViewController with one button, when i push it go to second view
Second view(aka mainview): a Windows with Tab Bar with 2 tabbar item who switch between:
Second view A: Normal UIViewController with some elements
Second view B: UITableViewController
Can someone give me an advice where to start reading or some examples?
thx
my advice is to read sample code form apple there you can also find coding how to s so good luck, or you can find example codes all over the stack just search. for example navigation based app:
UINavigationController doesn't work in a the moreNavigationController of a UITabBarController
or simple transition:
SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:screen animated:YES];
[screen release];
hope it helps bye
wblade
You need to start with view based application. And then create a UITabbarController in you appDelegate file.
Appdelegate.h
UITabBarController *tabBarController;
// set properties
Appdelegate.m
// Synthsize
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate=self;
//Adding Search,Nearby,Map,AboutUs,Favorites Tabs to tabBarController
Search * search = [[Search alloc] init];
UINavigationController *searchNav = [[UINavigationController alloc] initWithRootViewController:search];
Nearby* nearby = [[Nearby alloc] init];
UINavigationController *nearbyNav = [[UINavigationController alloc] initWithRootViewController:nearby];
Map* map = [[Map alloc] init];
UINavigationController *mapNav = [[UINavigationController alloc] initWithRootViewController:map];
AboutUs* aboutUs = [[AboutUs alloc] init];
UINavigationController *aboutUsNav = [[UINavigationController alloc] initWithRootViewController:aboutUs];
Favorites* favorites = [[Favorites alloc] init];
UINavigationController *favoritesNav = [[UINavigationController alloc] initWithRootViewController:favorites];
NSArray* controllers = [NSArray arrayWithObjects:searchNav,nearbyNav,mapNav,aboutUsNav,favoritesNav, nil];
tabBarController.viewControllers = controllers;
[window addSubview:tabBarController.view];
You can accordingly manage in which tab you want to place navigation controller or only a view controller.
Then in each of the view controllers mentioned above you need to implement
- (id)init {}
in which you can set Tab name and image.

Navigation Items in UITableViewController are not appearing?

I am displaying a UITableViewController inside of a UITabBarController that is being presented modally:
-(IBAction)arButtonClicked:(id)sender{
//this is a uitableviewcontroller
ARViewController* arViewController = [[[ARViewController alloc] initWithNibName:#"ARViewController" bundle:nil]autorelease];
LeaderBoardTableViewController* lbViewController = [[[LeaderBoardTableViewController alloc] initWithNibName:#"LeaderBoardTableViewController" bundle:nil]autorelease];
lbViewController.title = #"Leaderboard";
arTabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
arTabBarController.viewControllers = [NSArray arrayWithObjects:arViewController, lbViewController, nil];
arTabBarController.selectedViewController = arViewController;
[self presentModalViewController:arTabBarController animated:YES];
}
In my viewDidLoad for arViewController method I am setting the navigation items:
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
self.clearsSelectionOnViewWillAppear = NO;
self.title = #"AR";
leaderBoardButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
target:self
action:#selector(leaderBoardButtonClicked:)];
self.navigationItem.rightBarButtonItem = leaderBoardButton;
}
My navigation bar doesn't appear when it is inside of the UITabBarController, but when I push the view itself I am able to see it.
What am I missing?
Heh, I've been stumped by this too. What you need to do is send the rootViewController.
I've never used a tabBar for anything except on the main screen but ur code will probably look like this:
after arTabBarController.selectedViewController = arViewController;
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController: arTabBarController] autorelease];
[self presentModalViewController: navController animated:YES];
Like I said I haven't done it with a tabBar but I'm pretty sure it will be something along these lines
I needed to add a UINavigationBar:
ARViewController* arViewController = [[[ARViewController alloc] initWithNibName:#"ARViewController" bundle:nil]autorelease];
UINavigationController *arNavController = [[UINavigationController alloc] initWithRootViewController:arViewController];
LeaderBoardTableViewController* lbViewController = [[[LeaderBoardTableViewController alloc] initWithNibName:#"LeaderBoardTableViewController" bundle:nil]autorelease];
lbViewController.title = #"Leaderboard";
UINavigationController *lbNavController = [[UINavigationController alloc] initWithRootViewController:lbViewController];
arTabBarController = [[UITabBarController alloc] init];//initWithNibName:nil bundle:nil];
arTabBarController.viewControllers = [NSArray arrayWithObjects:arNavController, lbNavController, nil];
arTabBarController.selectedViewController = arNavController;
[self presentModalViewController:arTabBarController animated:YES];
There is a simple solution, put setting in view will appear
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:animated];
}
hope it help some newbies;

UITabBar with UINavigationController in code

I've currently got a UITabBar with 5 screens calling UIViews. That part works fine but I want to put in a UINavigationController in a couple of them. I have found a few tutorials that work fine but all of them implement it in IB and I want to avoid that if possible.
I'm lost as to where to implement the UINavigationController, should I do it in the App Delegate with the UITabBar and call the navigation controller from the UIView or should I create it in the UIView class?
I've tried about 8 different ways and always ends up with either the Navbar not working, no nav bar at all or the app crashing.
Currently I create the tab bar like this:
tabBarController = [[UITabBarController alloc] init];
ScreenA *screenA = [[ScreenA alloc] initWithNibName:#"ScreenA" bundle:nil];
//more here
tabBarController.viewControllers = [NSArray arrayWithObjects:screenA, ...., nil];
[window addSubview:tabBarController.view];
And in the initWithNibName I have this:
self.title = #"Screen A";
self.tabBarItem.image = [UIImage imageNamed:#"someImage.png"];
Ok, do it like this...
tabBarController = [[UITabBarController alloc] init];
searchTableViewController = [[SearchTableViewController alloc] init];
UINavigationController *searchTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchTableViewController] autorelease];
[searchTableViewController release];
searchMapViewController = [[SearchMapViewController alloc] init];
UINavigationController *mapTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchMapViewController] autorelease];
[searchMapViewController release];
tabBarController.viewControllers = [NSArray arrayWithObjects:searchTableNavController, mapTableNavController, nil];