shake

how to detect and program around shakes for the iphone

北城以北 提交于 2019-11-29 02:27:36
I'm trying to implement the shake "tutorial" on this page, but I think I'm missing something. I copied his accelerometer function into myAppViewController.m file and put some nslogs in there to see if it even gets into the function when I use the simulators "shake" function. Nothing shows up in the debug console. http://mithin.in/2009/07/28/detecting-a-shake-using-iphone-sdk Can anyone explain what I might be missing? Or point me to a tutorial? I found this, which looks promising, but I don't know how to "put it in a UIView" How do I detect when someone shakes an iPhone? EDIT - now here's my

How to pass a boolean between intents

风流意气都作罢 提交于 2019-11-27 22:03:24
I need to pass a boolean value to and intent and back again when the back button is pressed. The goal is to set the boolean and use a conditional to prevent multiple launches of a new intent when an onShake event is detected. I would use SharedPreferences, but it seems it does not play nice with my onClick code and I'm not sure how to fix that. Any suggestions would be appreciated! public class MyApp extends Activity { private SensorManager mSensorManager; private ShakeEventListener mSensorListener; /** Called when the activity is first created. */ @Override public void onCreate(Bundle

How to detect shake motion in iPhone

孤街醉人 提交于 2019-11-27 17:38:40
问题 On the shake of the iPhone device i want some function to be called, i dont know how to recognize shake so i tried some link and tried this code - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { if(event.type == UIEventSubtypeMotionShake) { NSLog(@"called"); [self.view setBackgroundColor:[UIColor greenColor]]; } } - (BOOL)canBecomeFirstResponder { return YES; } But alas no luck so can you please let me know how i can do the same Thanks and Regards 回答1: As per the above

how to detect and program around shakes for the iphone

房东的猫 提交于 2019-11-27 16:42:35
问题 I'm trying to implement the shake "tutorial" on this page, but I think I'm missing something. I copied his accelerometer function into myAppViewController.m file and put some nslogs in there to see if it even gets into the function when I use the simulators "shake" function. Nothing shows up in the debug console. http://mithin.in/2009/07/28/detecting-a-shake-using-iphone-sdk Can anyone explain what I might be missing? Or point me to a tutorial? I found this, which looks promising, but I don't

How to stop the UITextField from responding to the shake gesture?

蓝咒 提交于 2019-11-27 07:13:31
问题 By default, if you shake the iPhone while entering text in a UITextField , a little box will appear asking if you want to undo typing. How can I prevent this from happening? I looked through the UITextField, UITextFieldDelegate, and UITextInputTraits docs and found nothing relating to shaking. Presumably I could subclass UITextField to ignore the shake event, but I'm not exactly confident in my ability to not screw other things up. I'd love something like textField.respondsToShake = FALSE;

How to use Shake API in iPhone SDK 3.0?

你。 提交于 2019-11-27 03:52:06
Apple annonced Shake API in iPhone SDK 3.0. I can not find any information regarding this new feature. Who knows about how to use it? Any example, link will be good. The APIs you are looking for are in UIResponder : - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event; - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event; - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event; Generally you just implement this: - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventSubtypeMotionShake) { //Your code

How to pass a boolean between intents

拥有回忆 提交于 2019-11-26 20:54:29
问题 I need to pass a boolean value to and intent and back again when the back button is pressed. The goal is to set the boolean and use a conditional to prevent multiple launches of a new intent when an onShake event is detected. I would use SharedPreferences, but it seems it does not play nice with my onClick code and I'm not sure how to fix that. Any suggestions would be appreciated! public class MyApp extends Activity { private SensorManager mSensorManager; private ShakeEventListener

How to refresh app upon shaking the device?

戏子无情 提交于 2019-11-25 23:36:00
问题 I need to add a shake feature that will refresh my Android application. All I find of documentation involves implementing the SensorListener , but Eclipse tells me it\'s deprecated and suggest SensorEventListener . Anybody that has a nice guide to how I go about creating this shake controller ? 回答1: Here is an example code. Put this into your activity class: /* put this into your activity class */ private SensorManager mSensorManager; private float mAccel; // acceleration apart from gravity

How do I detect when someone shakes an iPhone?

做~自己de王妃 提交于 2019-11-25 22:45:32
问题 I want to react when somebody shakes the iPhone. I don\'t particularly care how they shake it, just that it was waved vigorously about for a split second. Does anyone know how to detect this? 回答1: In 3.0, there's now an easier way - hook into the new motion events. The main trick is that you need to have some UIView (not UIViewController) that you want as firstResponder to receive the shake event messages. Here's the code that you can use in any UIView to get shake events: @implementation