如果我在下面有这个代码告诉UIPicker如果没有选择任何东西将脚设置为1,我怎么能延迟这个动作几秒钟?
// If feet values are zero.
if (([feetPicker selectedRowInComponent:0] == 0 & [feetPicker selectedRowInComponent:1] == 0)){
// Set to one foot.
[feetPicker selectRow:1
inComponent:1
animated:YES];
}
答案 0 :(得分:2)
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(fireMethod) userInfo:nil repeats:NO];
只要您想启动计时器,就可以放置上述代码。
-(void)fireMethod {
// If feet values are zero.
if (([feetPicker selectedRowInComponent:0] == 0 & [feetPicker selectedRowInComponent:1] == 0)){
// Set to one foot.
[feetPicker selectRow:1
inComponent:1
animated:YES];
}
}