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

iJustinCabral

macrumors member
Original poster
Jul 8, 2012
58
0
My code right now is

Code:
-(void)viewWillAppear:(BOOL)animated
{

[super viewWillAppear:animated];

[self becomeFirstResponder];

}


-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{

if (motion == UIEventSubtypeMotionShake)
{
[self.theList removeAllObjects];
NSLog (@"You shook the device. New List Count %d",self.theList.count);
}

}

-(void)motionEnded:(UIEventSubtype)motion withEvent(UIEvent *)event
{
NSLog(@"Device finished shaking");
}

Both NSLogs are not appearing in the debugger, so the device isn't getting this method sent to it.

I thought i did everything right but the device still wont recognize the shake...any idea what I'm missing or doing wrong?
 

Reason077

macrumors 68040
Aug 14, 2007
3,605
3,644
The object where you implemented these methods needs to be the "first responder" in order for UIEvents to be delivered to it.

Make sure you've implemented canBecomeFirstResponder to return YES, and are calling becomeFirstResponder at some point.
 

iJustinCabral

macrumors member
Original poster
Jul 8, 2012
58
0
Implemented

Code:
-(BOOL)canBecomeFirstResponder
{
return YES;
}

with the rest of my code and it worked perfect. Wonder why I missed that in the documentation.

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