显示UILabel*秒; 除了NSTimer以外的其他方式?

Emi*_*mil 2 iphone xcode objective-c

有没有其他方式显示对象/按钮/任何东西,例如3秒,而不是NSTimer?
我可以使用动画来做到这一点吗?

ken*_*ytm 5

您可以使用-performSelector:withObject:afterDelay:,但它在内部使用计时器.

[theLabel performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:3];
Run Code Online (Sandbox Code Playgroud)

您不能使用-setHidden:此方法,因为1它不是对象,但您可以使用NSInvocation.

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];
Run Code Online (Sandbox Code Playgroud)