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 09-15-2008, 12:03 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Ireland
Age: 21
Posts: 472
kieran12 is on a distinguished road
Question UIButton properties

This should be really simple but I can't figure it out. I have a button and an on/off switch. When the witch is set to on I want the button to be visible and when it is set to off I want the button to be hidden. The switch is called solutionSlider and the button is called button. Here's my code:

Code:
if (solutionSlider.on = FALSE) 
		button.hidden = TRUE;
	else if (solutionSlider.on =TRUE) 
		button.hidden = FALSE;
The switch doesn't seem to have any effect on the button. Any ideas?
__________________
On the iOS App Store
kieran12 is offline   Reply With Quote
Old 09-15-2008, 12:53 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2008
Posts: 69
Akamojo is on a distinguished road
Default

Quote:
Originally Posted by kieran12 View Post
This should be really simple but I can't figure it out. I have a button and an on/off switch. When the witch is set to on I want the button to be visible and when it is set to off I want the button to be hidden. The switch is called solutionSlider and the button is called button. Here's my code:

Code:
if (solutionSlider.on = FALSE) 
		button.hidden = TRUE;
	else if (solutionSlider.on =TRUE) 
		button.hidden = FALSE;
The switch doesn't seem to have any effect on the button. Any ideas?
In your if statement you are setting the value of solutionSlider.on. You are using the assignment operator (=) not the comparison operator (==).

I do that from time to time.

An easier way would be to do this single statement:

button.hidden = !solutionSlider.on;

-Darrell
__________________
Akamojo Software
Akamojo is offline   Reply With Quote
Old 09-15-2008, 01:53 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Ireland
Age: 21
Posts: 472
kieran12 is on a distinguished road
Unhappy Thankyou

Thanks that got it working.

What I'm really trying to do is make is a button in a different view hidden. The switch is in settingsView and the button is in rulesView. Here is my .h files:

Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>


@class RulesView;

@interface SettingsView : UIView {
	
	IBOutlet UISwitch *solutionSlider;
	IBOutlet UISwitch *soundSlider;
	IBOutlet UISwitch *shakeSlider;
	
}

-(IBAction)solutionSlider:(id)sender;
-(IBAction)soundSlider:(id)sender;
-(IBAction)shakeSlider:(id)sender;

@end

Code:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface RulesView : UIView {
	IBOutlet UIButton *showAnswer;
}

//this is the method/action which contains the code to load the answer site
-(IBAction)showAnswer:(id)sender;

@end
The button I want the switch to hide is called showAnswer.

Could you tell me what I'm doing wrong. I have a rough idea (settingsView doesn't know about showAnswer button because it's in a different view) and I thought all I had to do was add the @class part) but can;t get it to work. Oh I also added

Code:
#import "RulesView.h"
to my settingsView.m file
__________________
On the iOS App Store
kieran12 is offline   Reply With Quote
Reply

Bookmarks

Tags
boolean, simple, uibutton, uiswitch

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: 333
9 members and 324 guests
2Apps1Day, akacaj, Domele, michelle, NSString, SLIC, soohyun, Techgirl-52, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,886
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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