Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-20-2008, 05:53 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 11
Default conditional animation statement?

I am trying to create a set of if statements, depending on the initial position of 3 objects, will decide which position they all move to. (does that make sense?)
Here is my code i am trying to implement it into:

- (void)move {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
imageView1.center = Center1;
imageView2.center = Center2;
imageView3.center = Center3;
[UIView commitAnimations];
}

ive tried using:

if (imageView1.center == Center2) {
imageView1.center = Center1;
imageView2.center = Center3;
imageView3.center = Center2
}
else if (imageView1.center = Center3) {
imageView1.center = Center1
imageView2.center = Center2;
imageView3.center = Center3;
}


but i get the error
"error: invalid operands to binary =="


its probably really simple, but im stumped.
can any one help.

thanks in advance
Bollywood is offline   Reply With Quote
Old 12-20-2008, 07:48 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 486
Default

Quote:
Originally Posted by Bollywood View Post
I am trying to create a set of if statements, depending on the initial position of 3 objects, will decide which position they all move to. (does that make sense?)
Here is my code i am trying to implement it into:

- (void)move {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
imageView1.center = Center1;
imageView2.center = Center2;
imageView3.center = Center3;
[UIView commitAnimations];
}

ive tried using:

if (imageView1.center == Center2) {
imageView1.center = Center1;
imageView2.center = Center3;
imageView3.center = Center2
}
else if (imageView1.center = Center3) {
imageView1.center = Center1
imageView2.center = Center2;
imageView3.center = Center3;
}


but i get the error
"error: invalid operands to binary =="


its probably really simple, but im stumped.
can any one help.

thanks in advance
Let's play spot the coding errors game:

1) missing ; after imageView3.center = Center2
2) missing ; after imageView1.center = Center1
3) you are assigning a value with (imageView1.center = Center3), if you want to see if they are equal you need ==

Anyone else?
CommanderData is offline   Reply With Quote
Old 12-20-2008, 10:35 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 11
Default

Quote:
Originally Posted by CommanderData View Post
Let's play spot the coding errors game:

1) missing ; after imageView3.center = Center2
2) missing ; after imageView1.center = Center1
3) you are assigning a value with (imageView1.center = Center3), if you want to see if they are equal you need ==

Anyone else?
whoops....
the coding was correct in my app, i just copied it into the forum with errors.

I worked it out anyhow, I needed to compare the two values like this:
if (CGRectContainsPoint([imageView1 frame], Center2)) {
Bollywood is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:13 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0