Randomize UIButton
I have a button that randomizes its position when I load the app, but I need it to randomize every time I click it. right now I use this code as the x and y coordinates, and it works fine for randomizing when i first open the app.
int x1 = arc4random() % 230;
int y1 = arc4random() % 426;
also, this is the code for a timer i have for the button to pop up again.
-(void)buttonPressed1UIButton*)button {
[button setHidden:YES];
[NSTimer scheduledTimerWithTimeInterval:2
target:self selector:@selector(showButton1
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:button, @"button", nil]
repeats:NO];
}
- (void)showButton1NSTimer*)timer {
[[[timer userInfo] objectForKey:@"button"] setHidden:NO];
}
How can I make the button randomize every time i click on it?
|