Hacer sengul Akac
Hacer sengul Akac

Reputation: 683

how to move an image in objective c

I want to move image to another x,y position. I try this code but not work it crash after 3 seconds. The error is: 2012-01-17 12:40:47.213 YapiKrediDemo[1986:207] -[Sozlesme moveImage:]: unrecognized selector sent to instance 0x6c316c0.

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

image1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"GirisButton.png"]];

[NSTimer scheduledTimerWithTimeInterval: 3
                                 target: self
                               selector:@selector(moveImage:)
                               userInfo: nil repeats:YES];
}

-(void) moveImage
{
//[image1 setCenter: CGPointMake(634, 126)];
CGPoint pointOne=CGPointMake(634, 126);
image1.center=pointOne;
}  

How can I solve ?

Upvotes: 0

Views: 5314

Answers (2)

V1ru8
V1ru8

Reputation: 6147

The selector is @selector(moveImage). No : at the end. Or you have to add a parameter to the moveImage method. That's what you should do. - (void)moveImage:(NSTimer*)timer

Upvotes: 1

Shai Mishali
Shai Mishali

Reputation: 9382

Your selector needs to be @selector(moveImage) without the colon. moveImage: would mean a parameter is expected, while your method delceration below doesn't accept any parameters.

You could also just change the frame.

 CGRect myFrame = image1.frame;
 myFrame.origin.x = 634;
 myFrame.origin.y = 126;
 image1.frame = myFrame;

Upvotes: 2

Related Questions