Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sakthivadivel.a

macrumors newbie
Original poster
Oct 31, 2011
13
0
chennai - -India
I am developing an application for iPhone (iOS), as i am new to the apple technology having doubt. Is it possible to spin a pickerview control (or) move the selection indicator in pickerview automatically by shaking the iphone (i,e) i want to select values from pickerview either randomly or one after other by shaking the phone, if its so help in this regard.

Thanks in Advance.

sakthi.....:(:(
 
Last edited:
Yes.... You can use movement of the phone to do anything you want programmatically.
 
could you please explain it?

Could you please explain little elaborately technically, what method i have to use, how pickerview control receives the shake gesture.

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.subtype == UIEventSubtypeMotionShake)
{

self.view.backgroundColor = [UIColor redColor];


}
}

using the above method i can easily change the iphone background color wih respect to the gesture, but my doubt is how pickerview scrolls with respect to the gesture.

little elaboration highly appreciated.

thanks
 
Last edited:
Maybe read the pickerview docs, specifically the bits about animating it to a position? Or do you want us to read that for you and write your code for you? It's not difficult, detect the shake gesture, pick a random index, animate the pickerview.
 
where to pick the random index?

I don't know how to initiate it, from where to pick the random index. If possible simple code for that is very helpful for me. I think the above MOTIONBEGAN is the method which detects the gesture, i just want the code for inside this method how pickerview control receives the control or as you said index value for the shake gesture.

Expecting the code.

Thanks and regards
sakthi
 
lol, "expecting the code"? This guy is too much. Who does he think he is, Steve Jobs?
 
For what it's worth, I'm pretty sure he's not trying to be as rude as it's coming across. Sounds like English isn't his first language.
 
I tried it

I tried but i am not getting the solution,


-(void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
NSString *string = [NSString stringWithFormat:mad:"%@",[list objectAtIndex:row]];
labelField.text=string;
pickerView.hidden = NO;
}

The above delegate method receives the control when we select any values in the pickerview by touch, but i didn't know how to write above mentioned delegate method functionalities into the below method,

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.subtype == UIEventSubtypeMotionShake)
{
//self.view.backgroundColor = [UIColor redColor];

//self.view.frame
self.view.backgroundColor = [UIColor redColor];
//pickerView.hidden = TRUE;
//[self.view removeFromSuperview:pickerView];


/*if (! isSpinning)
{
[pickerView selectRow:(kRowMultiplier - 1) * [list count] -12 inComponent:0 animated:YES];
}*/
}
}


anyway i will try and get back with a solution soon.


Thanks
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.