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

View Single Post
Old 03-18-2010, 02:47 PM   #1 (permalink)
joeprogrammer
Registered Member
 
Join Date: Dec 2009
Posts: 10
joeprogrammer is on a distinguished road
Default UI button not showing - please help

I have an interesting problem. When I add a UIImageView it works fine

This code works:
- (void) showAd {

CGRect myAdRect = CGRectMake(0.0f, 0.0f, 320.0f, 480.0f);
UIImageView *myAd = [[UIImageView alloc] initWithFrame:myAdRect];
[myAd setImage:[UIImage imageNamed:@"Empty Red Box.png"]];
myAd.alpha = 0.0f;
[self.view addSubview:myAd];

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3];
myAd.alpha = 1.0f;
myAdButton.alpha = 1.0f;
[UIView commitAnimations];

[myAd release];
}


BUT, when I try to do something very similar adding a UIButton like this:
- (void) showAd {

//create button
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(100,200, 100, 50); // position in the parent view and set the size of the button
[myButton setTitle:@"Click Me!" forState:UIControlStateNormal];
//add targets and actions
[myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
// add to a view
[self.view addSubview:myButton];

[myButton release];
}


It doesn't work. By doesn't work, I mean no button appears on the screen. I have no idea what I could be doing wrong.

Ideas?
joeprogrammer is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,544
Threads: 94,068
Posts: 402,680
Top Poster: BrianSlick (7,989)
Welcome to our newest member, CMSLdesign
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:53 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.