gpt4 book ai didi

iphone - 显示 UILabel * 秒;除了 NSTimer 之外还有其他方法吗?

转载 作者:行者123 更新时间:2023-12-03 20:24:24 25 4
gpt4 key购买 nike

除了使用 NSTimer 之外,还有其他方式来显示对象/按钮/其他内容,例如 3 秒吗?
我可以使用动画来做到这一点吗?

最佳答案

您可以使用-performSelector:withObject:afterDelay:,尽管它在内部使用计时器。

[theLabel performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:3];

您不能将 -setHidden: 与此方法一起使用,因为 1 不是对象,但您可以使用 NSInitation

NSInvocation* invoc = [NSInvocation invocationWithMethodSignature:[theLabel methodSignatureForSelector:@selector(setHidden:)]];
[invoc setTarget:theLabel];
[invoc setSelector:@selector(setHidden:)];
BOOL yes = YES;
[invoc setArgument:&yes atIndex:2];
[invoc performSelector:@selector(invoke) withObject:nil afterDelay:3];

关于iphone - 显示 UILabel * 秒;除了 NSTimer 之外还有其他方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2257482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com