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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 03-10-2010, 04:47 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
Angry Button Issues

I have the following code implemented to create a button and also make it disappear once it is clicked but instead the button stays where it is when clicked and doesnt go away. please help.




- (void)loadView {

self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

self.view.backgroundColor = [UIColor whiteColor];

UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];

button1.frame = CGRectMake(110, 200, 100, 30);

[button1 setTitle:@"Tap Me" forState:UIControlStateNormal];

[button1 addTarget:self action:@selector(buttonPressed)
forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:button1];


}

-(void)buttonPressed {

setHidden: YES;

}
wardyfloyd is offline   Reply With Quote
Old 03-10-2010, 04:50 PM   #2 (permalink)
Will Work for Food!
 
itzdark's Avatar
 
Join Date: Apr 2009
Posts: 579
Send a message via AIM to itzdark Send a message via MSN to itzdark
Default

Code:
- (void)loadView {

self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

self.view.backgroundColor = [UIColor whiteColor];

UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];

button1.frame = CGRectMake(110, 200, 100, 30);

[button1 setTitle:@"Tap Me" forState:UIControlStateNormal];

[button1 addTarget:self action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:button1];


}

-(void)buttonPressed:(UIButton*)button {

[button setHidden:YES];

}
__________________

Check out my apps

Developers, check out study buddy. I use it everytime I code. It's great for those late night coding sessions.
Unofficial Ad Hoc Distribution Guide || Join my cooperative ad hoc testing group
iSoothe Promotional Video
Contact Me
itzdark is offline   Reply With Quote
Old 03-10-2010, 04:53 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
Default

Thank you so much. that worked like a charm.
wardyfloyd is offline   Reply With Quote
Old 03-10-2010, 05:17 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
Default

Hey, I have another problem. I want this button to return every couple seconds and wrote out a timer but i dont know what selector to use. great if you could give me a little more help.



- (void)loadView {

self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

self.view.backgroundColor = [UIColor whiteColor];

UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];

button1.frame = CGRectMake(110, 200, 100, 30);

[button1 setTitle:@"Tap Me" forState:UIControlStateNormal];

[button1 addTarget:self action:@selector(buttonPressed
forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:button1];


}

-(void)buttonPressedUIButton*)button {

[button setHidden:YES];
[NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(buttonPressed
userInfo:nil
repeats:YES];

}
wardyfloyd is offline   Reply With Quote
Old 03-10-2010, 05:23 PM   #5 (permalink)
Will Work for Food!
 
itzdark's Avatar
 
Join Date: Apr 2009
Posts: 579
Send a message via AIM to itzdark Send a message via MSN to itzdark
Default

Code:
[NSTimer scheduledTimerWithTimeInterval:5
target:self
selector:@selector(showButton:)
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:button, @"button", nil]
repeats:NO];

- (void)showButton:(NSTimer*)timer {
     [[[timer userInfo] objectForKey:@"button"] setHidden:NO];
}
__________________

Check out my apps

Developers, check out study buddy. I use it everytime I code. It's great for those late night coding sessions.
Unofficial Ad Hoc Distribution Guide || Join my cooperative ad hoc testing group
iSoothe Promotional Video
Contact Me
itzdark is offline   Reply With Quote
Old 03-10-2010, 05:59 PM   #6 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
Default

hey, thanks again thats alot of help, but now, after clicking the button a few times, the intervals get shorter and break. what can i do to make them stay the same?
wardyfloyd is offline   Reply With Quote
Old 03-10-2010, 06:22 PM   #7 (permalink)
Will Work for Food!
 
itzdark's Avatar
 
Join Date: Apr 2009
Posts: 579
Send a message via AIM to itzdark Send a message via MSN to itzdark
Default

did u change repeats from yes to no?
__________________

Check out my apps

Developers, check out study buddy. I use it everytime I code. It's great for those late night coding sessions.
Unofficial Ad Hoc Distribution Guide || Join my cooperative ad hoc testing group
iSoothe Promotional Video
Contact Me
itzdark is offline   Reply With Quote
Old 03-10-2010, 06:38 PM   #8 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 45
Default

nevermind when i reopened xcode the problem was fixed.
wardyfloyd is offline   Reply With Quote
Reply

Bookmarks

Tags
button, disappear, hide, iphone, uibutton

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: 259
22 members and 237 guests
@sandris, AdamL, ADY, Dani77, diyora, FAED, fredidf, F_Bryant, GHuebner, HDshot, headkaze, mer10, Oral B, prchn4christ, Rudy, smithdale87, stekki, tgjorgoski, Thompson22, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,752
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

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