Quote:
Originally Posted by heavenking
i'm trying to change the position of my image view after time delay like in the following code
Code:
CGPoint pointOne=CGPointMake(150, 200);
UIImageView *sampleImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hello.png"]];
[sampleImage performSelector:@selector(setCenter:) withObject:[NSValue valueWithCGPoint:pointOne] afterDelay:0.5];
it does not works properly because image view does not accept the nsvalue plz say any other solution to pass the cgpoint as the object. Thanks in advance   .
|
You can't pass non-object parameters using performSelector:withObject:afterDelay:
In order to do that, you'll need to create an additional method. Say you call it moveImage:
Code:
-(void) moveImage
{
[sampleImage setCenter: CGPointMake(150, 200)];
}
...
UIImageView *sampleImage=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hello.png"]];
[self performSelector: @selector(moveImage) withObject: nil afterDelay: 0.5];
There is another Cocoa feature called NSInvocation that lets you invoke an arbitrary method with any types of parameters much like the "performSelector" methods, but I haven't used it.