我正在尝试在另一个方法中创建一个方法,然后将该方法传递给我的计时器。我被困在NSTimer的selector
部分,并且不知道如何将我的方法传递给它。我想我可以像往常一样传递它:[self methodHere:parameter]
但它不起作用。
我在viewDidLoad中的bgTimer = [NStimer....
行收到两条警告:
的.m
- (void)viewDidLoad {
[super viewDidLoad]
timer = [NSTimer scheduledTimerWithTimeInterval:animationDuration target:self selector:@selector([self bgColorCycleWithOutlet:bgColor]) userInfo:nil repeats:YES];
}
- (void)bgColorCycleWithOutlet:(UIButton *)outlet {
if (time == 0) {
[self bgColorSwatchAnimationRed:232
green:152
blue:58
duration:5
outlet:outlet];
}
}
- (void)bgColorSwatchAnimationRed:(float)r green:(float)g blue:(float)b duration:(int)d outlet:(UIButton *)o {
[o setBackgroundColor:[UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:0.5]];
[UIView animateWithDuration:d animations:^{
[o setBackgroundColor:[UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]];
}];
}
答案 0 :(得分:2)
应该是:
@selector(bgColorCycleWithOutlet:)