Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.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 04-30-2008, 02:47 PM   #1 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 10
Default UIButton with an image

Ok I have been at this for a few hours now and it is starting to bug me a little bit, I am trying to create a UIButton with a UIImage associated to it, here's what I got. After I build and go, I see the button is there, but no image...any ideas? I have dropped the image into the project, so it's there

- (void)loadView {

// create an instance of UIView
UIView *myView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];

[myView setAutoresizingMask:UIViewAutoresizingFlexibleHeig ht|UIViewAutoresizingFlexibleWidth];
// set the background color of the view to black
myView.backgroundColor = [UIColor whiteColor];
// create a frame for the button to go in
CGRect frame = CGRectMake(30, 100, 260, 80);
// create a button
UIButton *snap_picture_button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
// set the frame of the button
snap_picture_button.frame = frame;
// create an image for the button
UIImage *snap_picture = [UIImage imageWithContentsOfFile:@"snap_photo.jpg"];
// set the image for the button
[snap_picture_button setBackgroundImage:snap_picture forState:UIControlStateNormal];
// enable the button
snap_picture_button.userInteractionEnabled = YES;
// add the button to the view
[snap_picture_button addTarget:myView
action:@selector(snapPhoto
forControlEvents:UIControlEventTouchUpInside];

// add the button to the view
[myView addSubview:snap_picture_button];

// add myView to the viewController
self.view = myView;
[myView release];
}
ddavtian is offline   Reply With Quote
Old 04-30-2008, 02:53 PM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 10
Default Re: UIButton with an image

Ahh found my issue, need to use this to get the image

+ (UIImage *)imageNamedNSString *)name
ddavtian 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
IB - UIButton title with a code and shadow marius1625 iPhone SDK Development 5 01-19-2009 01:10 PM
Subclassing UIButton gloubibou iPhone SDK Development 3 09-07-2008 09:01 AM
UIButton action no more working with iPhone SDK 2.0 lightforce iPhone SDK Development 2 07-13-2008 12:47 AM
display image from xml sangau001 iPhone SDK Development 2 06-15-2008 02:09 PM
UIButton toggle brianr iPhone SDK Development 2 04-29-2008 09:43 AM

Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,208
Threads: 38,991
Posts: 171,023
Top Poster: smasher (2,569)
Welcome to our newest member, JDBurgie
Powered by vBadvanced CMPS v3.1.0

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