假设对于段控制器中的示例,您采用这样的 0.1,0.2,0.5,0.10,0.20,0.30 值,然后见下文..
-(IBAction) segmentedControlIndexChanged{
switch (self.segmentedControl.selectedSegmentIndex) {
case 0:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.1
target: self
selector: @selector(methodName:)
userInfo: nil
repeats: YES];
break;
case 1:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.2
target: self
selector: @selector(methodName:)
userInfo: nil
repeats: YES];
break;
case 2:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.5
target: self
selector: @selector(methodName:)
userInfo: nil
repeats: YES];
break;
case 3:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.10
target: self
selector: @selector(methodName:)
userInfo: nil
repeats: YES];
break;
case 4:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.20
target: self
selector: @selector(methodName:)
userInfo: nil
repeats: YES];
break;
default:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.30
target: self
selector: @selector(methodName:)
userInfo: nil
repeats: YES];
break;
}
}