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 05-16-2011, 02:06 PM   #1 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 389
Esko2300 is on a distinguished road
Default UItoolBar With a Custom Icon

Im trying to place a Custom Icon on to a UIToolbar but when i do it the icon dosent come out correctly, this is the code im using for it anyone have any idea whats going wrong?
Code:
    UIImage *image = [UIImage imageNamed:@"webIcon.jpg"];
    webpageBtn = [[UIBarButtonItem alloc]initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(goToWebPage)];

[toolbar setItems:[NSArray arrayWithObject:webpageBtn]];
The icon shows the shape of the picture(which is a circle), here its just a globe indicating press this to go to the webpage, but when i see it in the app it shows only a white circle
Esko2300 is offline   Reply With Quote
Old 05-17-2011, 11:06 AM   #2 (permalink)
Awesome
 
Esko2300's Avatar
 
Join Date: Jun 2009
Location: New York, N.Y.
Posts: 389
Esko2300 is on a distinguished road
Default

I figured it out heres what i did, this piece of code will make it where you are able to insert any icon you want inside your Toolbar

Code:
    UIButton *webButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [webButton setFrame:CGRectMake(0, 0, 50, 40)];
    [webButton setImage:[UIImage imageNamed:@"webIcon.jpg"] forState:UIControlStateNormal];
    [webButton addTarget:self action:@selector(goToWebPage) forControlEvents:UIControlEventTouchDown];

    
    UIBarButtonItem *webpageBtn = [[UIBarButtonItem alloc]initWithCustomView:webButton];
    [webpageBtn setTarget:self];
    [webpageBtn setAction:@selector(goToWebPage)];

[toolbar setItems:[NSArray arrayWithObject:webpageBtn]];

Last edited by Esko2300; 05-17-2011 at 11:25 AM.
Esko2300 is offline   Reply With Quote
Reply

Bookmarks

Tags
custom app icons, uitoolbar

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: 360
6 members and 354 guests
doffing81, dre, iOS.Lover, Kirkout, MikaelBartlett, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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