如何在静态方法实现中调用selector?
我试过这个,但没有成功。我做错了什么?
WhiteScreenFader.m
+(void) fadeIn:(float)duration inView:(UIView *)view withAction:(SEL)selector
{
.
.
.
[NSObject performSelector:selector]; //??
}
ViewController.m
// I call static method like this
[WhiteScreenFader fadeIn:1.0 inView:self.view withAction:@selector(segue:)];
---更新 这是完整的实施
+(void) fadeIn:(float)duration inView:(UIView *)view withAction:(SEL)selector
{
// bielu uiview
UIView *whiteView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
[whiteView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[whiteView setBackgroundColor:[UIColor whiteColor]];
whiteView.alpha = 0;
[view addSubview:whiteView];
// fade to 0
[UIView animateWithDuration:duration delay:0 options:UIViewAnimationCurveEaseOut animations:^{
whiteView.alpha = 1;
} completion:^(BOOL finished){
[NSObject performSelector:selector];
}];
}