views:

180

answers:

2

Hi.

Are there any other way of displaying an object/button/whatever for for example 3 seconds than with a NSTimer?

Thank you :)

EDIT:

Could I use an animation to do this? I'll try.

+1  A: 

You could try:

[UIVIew beginAnimations:nil context:nil];
[UIView setAnimationDelay:3];
[UIView setAnimationDuration:0.1]; //or lower than 0.1
button.hidden = YES;
[UIView commitAnimations];

Marco

Marco
Typo in first bit:UIVIew (big I should be small)
Emil
It didn't work :/
Emil
+3  A: 

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

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

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];
KennyTM
Thanks.I think I'm going to go with the animation, tough ;)
Emil
Or you can just add a category to UILabel overloading setHidden: that accept an object, say NSNumber.- (void)setHidden:(NSNumber *)hide{ [super setHidden:[hide boolValue];}Then use the performSelector:withObject:afterDelay: method.Marco
Marco