我正在尝试为我的应用创建一个磁铁重置点,当有人单击重置按钮时,它会重置我使用的硬件,并且还会将橙色圆圈从橙色闪烁为绿色。...>
[NSThread detachNewThreadSelector:@selector(myMethod) toTarget:self withObject:nil];
- (void)myMethod {
UIImage *image = [UIImage imageNamed: @"orangeDot.png"];
[dot setImage: image];
sleep(1);
image = [UIImage imageNamed: @"greenDot.png"];
[dot setImage: image];
}
如您所见,这发生在线程上。
无论如何,这是我的问题:即使有1秒钟的睡眠,也不会显示 的orangeDot吗?
答案 0 :(得分:0)
-(void) onTick {
[self battery];
}
- (void) resetMagnet:(UIButton *) sender {
[[MySlateManager sharedManager] doReset];
if(![SettingsManager shared].isVibrationDisabled)
{
[[VibrationHelper sharedInstance]singleShortVibration];
}
NSLog(@"Testttt");
[self flickerOrange];
NSTimer *t = [NSTimer scheduledTimerWithTimeInterval: 0.1
target: self
selector:@selector(onTick)
userInfo: nil repeats:NO];
}
那行得通!