开发者

NSTimer on a label

开发者 https://www.devze.com 2022-12-20 13:07 出处:网络
im working with iphone sdk and i 开发者_JS百科got to show a label when the user clik a button but after some time the label deseapear, can i do that?Use NSObject\'s performSelector: withObject: afterD

im working with iphone sdk and i 开发者_JS百科got to show a label when the user clik a button but after some time the label deseapear, can i do that?


Use NSObject's performSelector: withObject: afterDelay: for that - it will setup NSTimer that performs selector for you. In button click handler:

...
myLabel.hidden = NO;
[self performSelector:@selector(hideView:) withObject:myLabel afterDelay:3];
...

- (void) hideView:(UIView*)inView{
   // You can also add animation here
   view.hidden = YES;
}

Note, that it is not guaranteed that hideView: will get called exactly after 3 sec.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号