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 Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 08-29-2009, 11:02 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 11
Talking Ratio button-press-to-change-label

Hi...

I am currently in the process of making an application which relys on a single button to change which label is viewed... but thats not where I am stuck...

I don't want the app to be a 50/50 answer... i want the probability of one of the labels showing up to be far less than the other...

anyone got any ideas or places where i can implement this method as I would like to get my app finished soon so that I can catch the new school year rush...

thanks guys
stirkles17 is offline   Reply With Quote
Old 09-02-2009, 10:29 AM   #2 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 18
Default

Quote:
Originally Posted by stirkles17 View Post
Hi...

I am currently in the process of making an application which relys on a single button to change which label is viewed... but thats not where I am stuck...

I don't want the app to be a 50/50 answer... i want the probability of one of the labels showing up to be far less than the other...

anyone got any ideas or places where i can implement this method as I would like to get my app finished soon so that I can catch the new school year rush...

thanks guys
You need 2 things. One make an IBAction method that runs when the button is pressed and executes your label changing code and wire it up to the Interface Builder button that will be clicked. And you need to randomly get the label and save it in the the labels text field.
For random use the int r = arc4random() % 100;
to get a random between 0 and 99;

Then use your if statement to determine which title gets shown more frequently.

// Show A 75% of the time
if (r<75) label.text="A"; else label.text="B";
wyattbiker is offline   Reply With Quote
Reply

Bookmarks

Tags
button, label, ratio, text

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: 263
16 members and 247 guests
ADY, Alsahir, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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