Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-17-2008, 02:18 PM   #1 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 6
MissileSilo is an unknown quantity at this point
Question How do I add an image to the Navigation bar?

I was able to add an image to a button on the navigation bar, but I don't want it to show the button, I just want it to show the image on the top right of the navigation bar.

Here's the code I've got so far:

Code:
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] 
       initWithImage:[UIImage imageNamed:@"logo.png"]  
       style:UIBarButtonItemStyleBordered target:self 
       action:@selector(action:)];
self.navigationItem.rightBarButtonItem = addButton;
Any suggestions are welcome. Thanks.
MissileSilo is offline   Reply With Quote
Old 08-27-2008, 08:05 AM   #2 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 75
hijinks is on a distinguished road
Default

bump.. i'd like to know this also
hijinks is offline   Reply With Quote
Old 08-27-2008, 11:40 AM   #3 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 36
P-development is on a distinguished road
Default

Quote:
Originally Posted by hijinks View Post
bump.. i'd like to know this also
Code:
UIImage *image = [UIImage imageNamed: @"yourimage.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
	 
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithCustomView: imageview];
self.navigationItem.rightBarButtonItem = button;
[imageview release];
[button release];
P-development is offline   Reply With Quote
Old 04-02-2009, 12:15 AM   #4 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 1
crowtopia is on a distinguished road
Default

For anyone that comes across this post, here is how you get an image to show up in the textView area of a navigation bar.

// Create your image
UIImage *image = [UIImage imageNamed: @"yourimage.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];

// set the text view to the image view
self.navigationItem.textView = imageView;
crowtopia is offline   Reply With Quote
Old 04-02-2009, 12:20 AM   #5 (permalink)
girls? any new species ?
 
sindhutiwari's Avatar
 
Join Date: Nov 2008
Location: INDIA
Posts: 547
sindhutiwari is an unknown quantity at this point
Send a message via MSN to sindhutiwari Send a message via Yahoo to sindhutiwari Send a message via Skype™ to sindhutiwari
Default

self.navigationItem.titleView = urimageview
__________________
In order to succeed, your desire for success has to be greater than your fear for failure
sindhutiwari is offline   Reply With Quote
Old 04-02-2009, 04:33 PM   #6 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 1
kbosu31 is on a distinguished road
Default Error thrown

Bare with me here I'm a newbie at this. When I try to add this to my code, I get a warning that says: unused variable 'imageview'? Then I get an error that says 'request for member textView in something not a structure union and ImageView undeclared? Is there a step I am missing here?



Quote:
Originally Posted by crowtopia View Post
For anyone that comes across this post, here is how you get an image to show up in the textView area of a navigation bar.

// Create your image
UIImage *image = [UIImage imageNamed: @"yourimage.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];

// set the text view to the image view
self.navigationItem.textView = imageView;

Last edited by kbosu31; 04-02-2009 at 09:16 PM.
kbosu31 is offline   Reply With Quote
Old 04-02-2009, 10:38 PM   #7 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: India
Posts: 138
JohnMabassa is an unknown quantity at this point
Default

Get the NavBar sample app from apple's sample code library It has everything related to manipulating navigation bar.


-John M
JohnMabassa is offline   Reply With Quote
Old 09-13-2010, 02:42 AM   #8 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 70
andrewtheeditor is on a distinguished road
Default

Quote:
Originally Posted by crowtopia View Post
For anyone that comes across this post, here is how you get an image to show up in the textView area of a navigation bar.

// Create your image
UIImage *image = [UIImage imageNamed: @"yourimage.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];

// set the text view to the image view
self.navigationItem.textView = imageView;
This works great in viewWillLoad, however when you want to navigate BACK to this view, the app crashes. Am I missing something?
andrewtheeditor is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 318
8 members and 310 guests
blueorb, givensur, guusleijsten, jbro, mer10, n00b, SLIC, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,880
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:04 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0