在目標詞的使用睡眠(6)爲停止處理, 放睡眠(6 )爲您解僱通知代碼: -
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (motion == UIEventSubtypeMotionShake) {
sleep(6);
[FlurryAnalytics logEvent:@"User shaked to update"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"CheckWeather" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"startWeatherNeue" object:nil];
if ([super respondsToSelector:@selector(motionEnded:withEvent:)])
[super motionEnded:motion withEvent:event];
}
}
,然後處理停止6秒鐘,然後通知起火後6 Seconde系列可能是它有助於您
其他
ü也使用的NSTimer: -
中的NSTimerü檢查您迴應陣列數> 0,如果其他條件和呼叫方法1秒時,你的反應陣列> 0,則調用NSNOtification方法
這裏我舉的例子: - 用的NSTimer
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
self.TimeOfActiveUser = [NSTimer scheduledTimerWithTimeInterval:01.0 target:self selector:@selector(checkInfoString) userInfo:nil repeats:YES];
}
-(IBAction)checkInfoString
{
if([responsearray count]>0)
{
[FlurryAnalytics logEvent:@"User shaked to update"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"CheckWeather" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"startWeatherNeue" object:nil];
if ([super respondsToSelector:@selector(motionEnded:withEvent:)])
{
[super motionEnded:motion withEvent:event];
}
}
else
{
NSLOG
}
}
謝謝nitin,我會嘗試在我的要求中檢查這個代碼,看看它是如何工作的! – 2012-09-28 08:41:47