这是我的代码。
-(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");
}
}
我想在我的设备上摇晃/运动。我使用了该代码,但它不起作用..
写下下面的代码...然后检查
-(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/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |