我已经搜索并搜索了这个问题的答案,但我找到的解决方案似乎不起作用,所以我想我做错了什么:我想调用这个方法
-(void)customFade:(UILabel *)theLabel withDelay:(float)delayAmount {
[UIView animateWithDuration:0.5
delay:delayAmount
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[theLabel setAlpha:1.0f];
[theLabel setAlpha:0];
}completion:nil];
}
从一个名为“ View Controller ”的 VC 到另一个,但尽管导入了它,但它未被识别...这是我在所需的 VC 上尝试的操作:
- (void)viewDidLoad {
[super viewDidLoad];
ViewController *ViewController = [[ViewController alloc] init];
[ViewController customFade:_label withDelay:0.3];
}
警告说““ViewController”没有可见的@interface声明选择器分配
”有人可以帮我吗?我对此有点陌生,谢谢
最佳答案
such an error usually happens when you have mistyped the name of the method, or that method doesn't belong to that class at all and doesn't exist in your class.
并确保一旦你的 VC 是 UIViewController 的子类
@interface ViewController : UIViewController
更改您的实例对象类型并检查一次
ViewController *vc = [[ViewController alloc] init];
[vc customFade:_label withDelay:0.3];
然后像这样改变动画
[UIView animateWithDuration:0.5
delay:delayAmount
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
[theLabel setAlpha:1.0f];
}completion:{
[theLabel setAlpha:0];
}];
有关更多信息,您可以从 here 获得引用
关于IOS/objective-C : call of another class(VC) method not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43114643/