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 08-24-2008, 06:09 PM   #1 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
chuck is on a distinguished road
Default Making shiny info button for About page?

I've noticed many iPhone apps have info buttons which looks like (i) and then they light up when tapped which takes you to the About page of the app. My app is complete except for this screen. Can someone tell me if this is a standard button and how I could add it in the Interface builder? I created my project as a View-based project, if that is relevant. Thanks in advance!
chuck is offline   Reply With Quote
Old 08-24-2008, 06:37 PM   #2 (permalink)
ZipZest.com
 
Join Date: Aug 2008
Posts: 43
mikeb is on a distinguished road
Default

I'm not 100% sure but I think you're talking about a UIButton with the type set to "Info Light" ([button setButtonType:UIButtonTypeInfoLight])
mikeb is offline   Reply With Quote
Old 08-24-2008, 06:45 PM   #3 (permalink)
I live @ iDevKit.com
 
Join Date: Jul 2008
Posts: 142
mxweas is an unknown quantity at this point
Default

I know it's in the Utility Application template when you go to make a new xcode project. UICatalog has it as well.

Max
mxweas is offline   Reply With Quote
Old 08-24-2008, 10:12 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Clinton Twp, MI
Posts: 106
rjgrune is on a distinguished road
Default

In interface builder just add a new button and then in the button attributes, use the drop down menu and instead of custom you can choose info light or dark. That seems to be the simplest way...and i'm pretty sure the highlighting of the button happens as a default setting of that too.
rjgrune is offline   Reply With Quote
Old 09-03-2008, 06:13 AM   #5 (permalink)
Registered Member
 
chuck's Avatar
 
Join Date: Aug 2008
Location: Berlin, Germany
Posts: 87
chuck is on a distinguished road
Default

Sorry, other projects came up in the meantime and am now just getting back to this issue.

I probably should've stated in my post that I was trying to put the info button on a navigation bar, but I assumed it didn't matter. So, I tried all the advice above and none of it works. I finally got it working by doing the following:

1. Create a button in the view (not the navigation bar!)
2. Set this button to be Info Light
3. Set the action for this button to be Touch Inside Up
4. Move the button to the navigation bar

If you move the button to the navigation bar before setting the info light property or the action, then you will no longer be able to access these attributes within the Interface Builder! In any case, thanks for the help to get me on the right track.
chuck is offline   Reply With Quote
Old 07-24-2009, 10:44 AM   #6 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 34
doanelinde is on a distinguished road
Default

Wait, how did you just add it to the navigation bar? I'm having trouble doing that, my navigation bar isn't visible in interface builder, it's coded in..
doanelinde is offline   Reply With Quote
Old 07-24-2009, 10:58 AM   #7 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by doanelinde View Post
Wait, how did you just add it to the navigation bar? I'm having trouble doing that, my navigation bar isn't visible in interface builder, it's coded in..
you can't add buttons to a navController... you need to set the leftBarButtonItem and rightBarButtonItem properties ...something like this...

Code:
UIBarButtonItem *b=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"trash.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(deleteCurrentMessage)];
self.navigationItem.rightBarButtonItem=b;
[b release];
Dutch is offline   Reply With Quote
Old 08-05-2009, 08:52 AM   #8 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 34
doanelinde is on a distinguished road
Default

Ah lovely stuff, cheers.

But if

Code:
 self.navigationItem.leftBarButtonItem = self.editButtonItem;
adds an edit button, what's the property for an info button? I tried self.infoButtonItem but that didn't work...



Edit: Ok well I found a list of all the default buttons but the info button isn't there...
Code:
   UIBarButtonSystemItemDone,
   UIBarButtonSystemItemCancel,
   UIBarButtonSystemItemEdit,
   UIBarButtonSystemItemSave,
   UIBarButtonSystemItemAdd,
   UIBarButtonSystemItemFlexibleSpace,
   UIBarButtonSystemItemFixedSpace,
   UIBarButtonSystemItemCompose,
   UIBarButtonSystemItemReply,
   UIBarButtonSystemItemAction,
   UIBarButtonSystemItemOrganize,
   UIBarButtonSystemItemBookmarks,
   UIBarButtonSystemItemSearch,
   UIBarButtonSystemItemRefresh,
   UIBarButtonSystemItemStop,
   UIBarButtonSystemItemCamera,
   UIBarButtonSystemItemTrash,
   UIBarButtonSystemItemPlay,
   UIBarButtonSystemItemPause,
   UIBarButtonSystemItemRewind,
   UIBarButtonSystemItemFastForward,
   UIBarButtonSystemItemUndo,        // iPhoneOS 3.0
   UIBarButtonSystemItemRedo,

Last edited by doanelinde; 08-05-2009 at 09:18 AM.
doanelinde is offline   Reply With Quote
Old 08-05-2009, 01:00 PM   #9 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

The way to do this is as I told you.

1. Download this Image http://cowboyprogramming.com/wp-cont.../07/info44.png

2. Place into your app's bundle.

3. Use this code

Code:
UIBarButtonItem *b=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"info44.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(deleteCurrentMessage)];
self.navigationItem.leftBarButtonItem=b;
[b release];
or

Code:
self.navigationItem.leftBarButtonItem=[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"info44.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showAbout)] autorelease];

Last edited by Dutch; 08-05-2009 at 01:04 PM.
Dutch is offline   Reply With Quote
Old 08-06-2009, 04:33 AM   #10 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 34
doanelinde is on a distinguished road
Default

Ok well that kind of works, but it's still not the standard info button, it's the info button inside a big chunky square button, which just looks wrong and unconventional.

There must be some standard way to put the actual info button up there rather than just stick an image inside the normal button no?
doanelinde is offline   Reply With Quote
Old 08-06-2009, 08:25 AM   #11 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by doanelinde View Post
Ok well that kind of works, but it's still not the standard info button, it's the info button inside a big chunky square button, which just looks wrong and unconventional.

There must be some standard way to put the actual info button up there rather than just stick an image inside the normal button no?
Here are the two images:

info44.png:

info44_glowing.png:

And this is the code I used.

Code:
	UIButton *btn=[[UIButton alloc] init];
	[btn setImage:[UIImage imageNamed:@"info44.png"] forState:UIControlStateNormal];
	[btn setImage:[UIImage imageNamed:@"info44_glowing.png"] forState:UIControlStateHighlighted];	
	[btn addTarget:self action:@selector(showAbout) forControlEvents:UIControlEventTouchUpInside];
	[btn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 20)];
	UIBarButtonItem *b=[[UIBarButtonItem alloc] initWithCustomView:btn];	
	self.navigationItem.rightBarButtonItem=b;
	[b release];
	[btn release];

To Produce This (it glows red when you click it).

Dutch is offline   Reply With Quote
Old 08-06-2009, 09:07 AM   #12 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 34
doanelinde is on a distinguished road
Default

That's perfect, thanks for the extra effort!
doanelinde is offline   Reply With Quote
Old 08-06-2009, 09:35 AM   #13 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 24
evanovic is on a distinguished road
Default

Quote:
Originally Posted by doanelinde View Post
Ok well that kind of works, but it's still not the standard info button, it's the info button inside a big chunky square button, which just looks wrong and unconventional.

There must be some standard way to put the actual info button up there rather than just stick an image inside the normal button no?
another way to do this using the standard info button is :

Code:
UIButton * infoDarkButtonType = [[UIButton buttonWithType:UIButtonTypeInfoLight] retain];
	infoDarkButtonType.frame = CGRectMake(0.0, 0.0, 25.0, 25.0);
	infoDarkButtonType.backgroundColor = [UIColor clearColor];
	[infoDarkButtonType addTarget:self action:@selector(infoButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
	UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] initWithCustomView:infoDarkButtonType];
	self.navigationItem.rightBarButtonItem = infoButton;
	[infoDarkButtonType release];
	[infoButton release];
evanovic is offline   Reply With Quote
Old 08-06-2009, 10:01 AM   #14 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 34
doanelinde is on a distinguished road
Default

Aha! Even better, cheers. Knew there must be some standard way with an info button up there, thanks for the help lads!
doanelinde is offline   Reply With Quote
Old 08-10-2009, 04:24 PM   #15 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 30
dsinc14 is on a distinguished road
Default

Quote:
Originally Posted by Dutch View Post
Here are the two images:

info44.png:

info44_glowing.png:

And this is the code I used.

Code:
	UIButton *btn=[[UIButton alloc] init];
	[btn setImage:[UIImage imageNamed:@"info44.png"] forState:UIControlStateNormal];
	[btn setImage:[UIImage imageNamed:@"info44_glowing.png"] forState:UIControlStateHighlighted];	
	[btn addTarget:self action:@selector(showAbout) forControlEvents:UIControlEventTouchUpInside];
	[btn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 20)];
	UIBarButtonItem *b=[[UIBarButtonItem alloc] initWithCustomView:btn];	
	self.navigationItem.rightBarButtonItem=b;
	[b release];
	[btn release];

To Produce This (it glows red when you click it).


I want to have a info button with out a toolbar, is there anyway to do that?
dsinc14 is offline   Reply With Quote
Old 08-11-2009, 07:35 AM   #16 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by dsinc14 View Post
I want to have a info button with out a toolbar, is there anyway to do that?
You should be able to use the same exact code - except change this:

Code:
self.navigationItem.rightBarButtonItem=b;
to this

Code:
[whateverUIView addSubview:b];
Dutch is offline   Reply With Quote
Old 04-09-2010, 06:56 AM   #17 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 1
emin3m is on a distinguished road
Default

Code:
UIButton *aboutButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[aboutButton addTarget:self action:@selector(aboutFoo:) forControlEvents:UIControlEventTouchUpInside];

[aboutButton setImage:[UIImage imageNamed:@"about.png"] forState:UIControlStateNormal];
	
UIBarButtonItem *iButton = [[UIBarButtonItem alloc] initWithCustomView: aboutButton];
    self.navigationItem.leftBarButtonItem = iButton;
dont tell me am leaking memory
emin3m is offline   Reply With Quote
Old 04-09-2010, 07:34 AM   #18 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by emin3m View Post
Code:
UIButton *aboutButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[aboutButton addTarget:self action:@selector(aboutFoo:) forControlEvents:UIControlEventTouchUpInside];

[aboutButton setImage:[UIImage imageNamed:@"about.png"] forState:UIControlStateNormal];
	
UIBarButtonItem *iButton = [[UIBarButtonItem alloc] initWithCustomView: aboutButton];
    self.navigationItem.leftBarButtonItem = iButton;
dont tell me am leaking memory
Is this a question, comment, or other?
Dutch is offline   Reply With Quote
Old 09-16-2010, 10:02 AM   #19 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Sanford, FL
Posts: 19
alyanm is on a distinguished road
Default

Quote:
Originally Posted by Dutch View Post
Is this a question, comment, or other?
Hey, thanks for this code, its been great for me. Unfortunately, since iOS4 it has stopped working for me -- the button is no longer visible, although tapping on the spot where it used to be does actually work. I don't suppose you have a fix for iOS4 perchance?

Thanks,
Alan
alyanm is offline   Reply With Quote
Old 07-19-2011, 05:04 PM   #20 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 178
dustbyter is on a distinguished road
Default

For this to work on iOS4.x you need to make a small change to the above code.
In short, you need to specify when creating the UIButton the frame to use, and to remove the image edge inset command.

My changes are below in red.

Hope this helps someone out

Code:
UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
	[btn setImage:[[ImageCache sharedManager] loadImage:@"info.png"] forState:UIControlStateNormal];
	[btn setImage:[[ImageCache sharedManager] loadImage:@"info_glowing.png"] forState:UIControlStateHighlighted];	
	[btn addTarget:self action:@selector(showInfo:) forControlEvents:UIControlEventTouchUpInside];
	//[btn setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 20)];
dustbyter is offline   Reply With Quote
Old 07-19-2011, 05:38 PM   #21 (permalink)
Registered Member
 
Objective Zero's Avatar
 
Join Date: Oct 2010
Posts: 1,210
Objective Zero is on a distinguished road
Default

If your trying to get an info button into a UINavigationBar, just follow this tutorial. Best thing is, no code required!
http://www.youtube.com/watch?v=ejbTc5f-w4c
__________________
Questions?

Check out my OCR app!
http://itunes.apple.com/app/ocr-pro/id486512712?mt=8
Objective Zero is offline   Reply With Quote
Old 01-27-2012, 09:10 AM   #22 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 1
chriskraus is on a distinguished road
Default

I have found another easy solution:

Code:
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoLight];
btn.frame = CGRectMake(0.0, 00, 25.0, 25.0);
[btn addTarget:self action:@selector(showabout:) forControlEvents:UIControlEventTouchUpInside];
        
UIBarButtonItem *aboutButton = [[UIBarButtonItem alloc] initWithCustomView:btn];        
        
self.navigationItem.rightBarButtonItem = aboutButton;
It is short and you do not need any images.
chriskraus is offline   Reply With Quote
Old 02-17-2012, 12:14 AM   #23 (permalink)
New User
 
Join Date: Feb 2012
Posts: 2
neerajNeeru is on a distinguished road
Default thanks

thank u so much dutch,, i also searching for ths solution..

Last edited by neerajNeeru; 02-17-2012 at 12:19 AM.
neerajNeeru is offline   Reply With Quote
Old 02-17-2012, 01:25 AM   #24 (permalink)
Scan Me !
 
MozyMac's Avatar
 
Join Date: Nov 2009
Posts: 608
MozyMac is on a distinguished road
Send a message via AIM to MozyMac Send a message via MSN to MozyMac Send a message via Yahoo to MozyMac
Default

Thanks for sharing !
MozyMac is offline   Reply With Quote
Reply

Bookmarks

Tags
button, info

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: 346
10 members and 336 guests
givensur, glenn_sayers, guusleijsten, ipodphone, jbro, mediaspree, mtl_tech_guy, Punkjumper, whitey99, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
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:34 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0