Quote:
Originally Posted by stirkles17
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";