显示UILabel *秒;除了NSTimer之外的其他方式? [英] Show a UILabel for * seconds; other ways than with NSTimer?

查看:132
本文介绍了显示UILabel *秒;除了NSTimer之外的其他方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有其他方式显示对象/按钮/等等,例如3秒比使用NSTimer?

我可以使用动画来执行此操作吗?

Are there any other way of displaying an object/button/whatever,for example 3 seconds than with an NSTimer?
Could I use an animation to do this?

推荐答案

你可以使用 -performSelector:withObject:afterDelay:,虽然它在内部使用了一个计时器。

You may use -performSelector:withObject:afterDelay:, though it uses a timer internally.

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

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

You cannot use -setHidden: with this method because 1 is not an object, but you can use 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];

这篇关于显示UILabel *秒;除了NSTimer之外的其他方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆