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 05-15-2011, 09:13 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 60
nathanl1192 is on a distinguished road
Default Sliders... HELP PLEASE!

Hi there,

I am reasonably new to development so please keep things as simple as possible.

I was wondering how to make a slider, which affects the function of a UIButton, if that makes sense.

So, If the slider is a value 0, then when the button is pressed a alert will show; but when the slider is a value 0.1, a sound will play.

Thanks so much,

Nathan

Running XCode 4.0
nathanl1192 is offline   Reply With Quote
Old 05-15-2011, 10:28 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default

Add a method in your controller.
Code:
-(IBAction)mySliderValueChanged:(id)sender;
Add an instance variable to store the slider value.
Add a slider to IB, connect it to mySliderValueChanged. You'll want to drag from the right side Connections inspector, rightmost pane, from the Value Changed event.
In mySliderValueChanged, put something like:
Code:
UISlider *slider = (UISlider *)sender;
slidersValue = slider.value;
Then, in your button press method:
Code:
if (slidersValue == 0)
      //Show alert
else
      //Play sound
architectpianist is offline   Reply With Quote
Old 05-15-2011, 10:47 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 60
nathanl1192 is on a distinguished road
Default

Thanks so much!
BUT!
Where do I declare slidersValue?
How do I create an instance variable to store it?
Thanks

Last edited by nathanl1192; 05-15-2011 at 10:51 AM.
nathanl1192 is offline   Reply With Quote
Old 05-15-2011, 10:51 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default

Header file.
architectpianist is offline   Reply With Quote
Old 05-15-2011, 10:52 AM   #5 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 60
nathanl1192 is on a distinguished road
Default

Quote:
Originally Posted by architectpianist View Post
Header file.
And How do I create an instance variable to store it?

Thanks again!
nathanl1192 is offline   Reply With Quote
Old 05-15-2011, 10:56 AM   #6 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

I think that is not usefull ask in a forum if you are not able to create a variable.....why not starting from a book like that
Beginning iPhone 4 Development: Exploring the iOS SDK: David Mark, Jack Nutting, Jeff LaMarche
__________________
dany_dev is offline   Reply With Quote
Old 05-15-2011, 10:57 AM   #7 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 60
nathanl1192 is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
I think that is not usefull ask in a forum if you are not able to create a variable.....why not starting from a book like that
Beginning iPhone 4 Development: Exploring the iOS SDK: David Mark, Jack Nutting, Jeff LaMarche
I disagree. I am a full time student who has decided to have a play around with xcode. I do not have the time to study fully. Asking in the forum gives me quick results from usually helpful people.
nathanl1192 is offline   Reply With Quote
Old 05-15-2011, 11:07 AM   #8 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by nathanl1192 View Post
I disagree. I am a full time student who has decided to have a play around with xcode. I do not have the time to study fully. Asking in the forum gives me quick results from usually helpful people.
lol.........are you joking right?
__________________
dany_dev is offline   Reply With Quote
Old 05-15-2011, 11:10 AM   #9 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 60
nathanl1192 is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
lol.........are you joking right?

What would I be joking about? I know learning code needs time which I don't have but I still want to give it a try.

Note: And I mean study xcode fully
nathanl1192 is offline   Reply With Quote
Old 05-15-2011, 11:45 AM   #10 (permalink)
Registered Member
 
Join Date: Jan 2011
Location: Tokyo
Posts: 163
kazbluesky is on a distinguished road
Default

I think he's serious, but he just misunderstands the system.

The forum (as I see it) wants you to have a go at doing it yourself and then when you get absolutely stuck you then ask if anyone can help you solving the problem that's beyond you. Basically, they want to help you because they struggled, but they expected you to struggle too - they don't just want to be unpaid teachers or code writers for you. Seems reasonable........

You will need to look at the books sooner or later though, or the YouTube vids, good luck.
kazbluesky is offline   Reply With Quote
Old 05-15-2011, 11:59 AM   #11 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 60
nathanl1192 is on a distinguished road
Default

Quote:
Originally Posted by kazbluesky View Post
I think he's serious, but he just misunderstands the system.

The forum (as I see it) wants you to have a go at doing it yourself and then when you get absolutely stuck you then ask if anyone can help you solving the problem that's beyond you. Basically, they want to help you because they struggled, but they expected you to struggle too - they don't just want to be unpaid teachers or code writers for you. Seems reasonable........

You will need to look at the books sooner or later though, or the YouTube vids, good luck.
I have spent a long time trying to do this myself, I have done web searches etc and watched countless tutorials. I am stuck. Is anyone going to help me?
nathanl1192 is offline   Reply With Quote
Old 05-15-2011, 01:27 PM   #12 (permalink)
Knows SQL
 
iisword's Avatar
 
Join Date: Oct 2009
Location: Somewhere the streets are on fire, the sewers are flooded, and the cats are high on catnip
Posts: 529
iisword is on a distinguished road
Default

Please tell me your not a college or high school student...
__________________
iisword is offline   Reply With Quote
Old 05-15-2011, 02:53 PM   #13 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 144
iAppDev is on a distinguished road
Default

this is what you do
Code:
		
		if ((myslider.value >= 0.0) && (myslider.value <= 1.0)) {
		   //your code to do methods goes here 
		}

if you don't understand this, then you seriously need to read a book or something or find online tutorials that will do pieces of this.
iAppDev is offline   Reply With Quote
Old 05-15-2011, 03:01 PM   #14 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 40
Epic Sandwich is on a distinguished road
Default

Seriously, follow this advice:

Quote:
Originally Posted by dany_dev View Post
I think that is not usefull ask in a forum if you are not able to create a variable.....why not starting from a book like that
Beginning iPhone 4 Development: Exploring the iOS SDK: David Mark, Jack Nutting, Jeff LaMarche
It's an excellent book, and I promise you that even after reading it for just one hour you'll be able to do what you're asking here with ease, and understand exactly what's going on at the same time.
Epic Sandwich is offline   Reply With Quote
Reply

Bookmarks

Tags
action, change, ibaction, slider

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: 370
6 members and 364 guests
doffing81, dre, iOS.Lover, Kirkout, MikaelBartlett, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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