这是我的代码。
-(void)motionBeganUIEventSubtype)motion withEventUIEvent *)event
{
[[NSNotificationCenter defaultCenter] addObserver:self
selectorselector(shake) name"shake" object:nil];
if(event.type == UIEventTypeMotion && event.subtype == UIEventSubtypeMotionShake)
{
// SOMETHING HERE
}
NSLog(@"motion Began");
}
else
{
NSLog(@"Shake Is Over");
}
}
我想在我的设备上摇晃/运动。我使用了该代码,但它不起作用..
Best Answer-推荐答案 strong>
写下下面的代码...然后检查
-(BOOL) canBecomeFirstResponder {
return YES;
}
-(void)motionEndedUIEventSubtype)motion withEventUIEvent *)event
{
//your stuff
}
-(void)viewDidAppearBOOL)animated {
[self becomeFirstResponder];
}
-(void)viewDidDisappearBOOL)animated {
[self resignFirstResponder];
}
让我知道它是否有效!!!
编码愉快!!!!
关于iphone - 我无法在我的设备上摇晃/移动,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/18285350/
|