iphone - 我无法在我的设备上摇晃/移动
<p><p>这是我的代码。</p>
<pre><code>-(void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
[ addObserver:self
selector:@selector(shake) name:@"shake" object:nil];
if(event.type == UIEventTypeMotion && event.subtype == UIEventSubtypeMotionShake)
{
// SOMETHING HERE
}
NSLog(@"motion Began");
}
else
{
NSLog(@"Shake Is Over");
}
}
</code></pre>
<p>我想在我的设备上摇晃/运动。我使用了该代码,但它不起作用..</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>写下下面的代码...然后检查</p>
<pre><code>-(BOOL) canBecomeFirstResponder {
return YES;
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//your stuff
}
-(void)viewDidAppear:(BOOL)animated {
;
}
-(void)viewDidDisappear:(BOOL)animated {
;
}
</code></pre>
<p>让我知道它是否有效!!!</p>
<p>编码愉快!!!!</p></p>
<p style="font-size: 20px;">关于iphone - 我无法在我的设备上摇晃/移动,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/18285350/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/18285350/
</a>
</p>
页:
[1]