Use an Image as NavigationBar Title

While working on my latest development project. The client wanted to have thier logo as the title of the NavigationBar. After some searching I found this code. It works well and is simple to understand.

UIImageView *image=[[UIImageView alloc]initWithFrame:CGRectMake(0,0,70,45)] ;
[image setImage:[UIImage imageNamed:@"Discount_Image.png"]];
[self.navigationController.navigationBar.topItem setTitleView:image];

Remove the current ViewController from the stack and push the next

UINavigationController *navController = self.navigationController;
pdViewController = [[ProductDetailViewController alloc] initWithNibName:@"ProductDetailView" bundle:nil];

NSMutableArray *controllers = [[self.navigationController.viewControllers mutableCopy] autorelease];
[controllers removeLastObject];
navController.viewControllers = controllers;
[navController pushViewController:pdViewController animated: YES];

Building an iPhone App Combining Tab Bar, Navigation and Tab

As I work my way through developing the app I am finding that there is more than one to make things happen on the iPhone. Most of the tutorials that you find on out there use Interface Builder to make sample apps.

In this tutorial Elizabeth Robson show you in great detail how TabBarcontrollers and Navigation Controllers can work together.

Thank you Elizabeth for a great tutorial

Syndicate content