如何在静态方法实现中调用选择器?
我试过这个,但没有成功。我究竟做错了什么?
WhiteScreenFader.m
+(void) fadeIn:(float)duration inView:(UIView *)view withAction:(SEL)selector
{
.
.
.
[NSObject performSelector:selector]; //??
}
视图控制器.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];
}];
}