Quote:
Originally Posted by iph_s
I can't figure out why that code works fine in iOS5 simulator but not in iOS4
Code:
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if(motion == UIEventSubtypeMotionShake)
{
NSLog(@"Shakde detected");
}
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
application.applicationSupportsShakeToEdit = YES;
}
-(BOOL)canBecomeFirstResponder {
return YES;
}
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
- (void)viewWillDisappear:(BOOL)animated {
[self resignFirstResponder];
[super viewWillDisappear:animated];
}
|
First of all, you should test hardware specific things like shake detection on a device, not on the sim.
The code you posted is confusing. You show a mixture of methods the belong in the app delegate and in your view controllers. Which code goes where?
Methods that belong in the app delegate, like applicationDidFinishLaunching, won't work in a view controller, and methods like canBecomeFirstResponder, viewWillAppear, and motionBegan belong in a view controller, and won't work in the app delegate.
Break out your code to show which methods go where.