09-17-2010, 08:21 PM
#1 (permalink )
Registered Member
Join Date: Aug 2010
Posts: 98
How To Make A Moving Image?
How do I make a UIImageView that constantly goes right to left while the view is open?
09-17-2010, 08:41 PM
#2 (permalink )
14 Year Old App Developer
Join Date: Mar 2010
Location: Texas
Posts: 242
Quote:
Originally Posted by
rTicker
How do I make a UIImageView that constantly goes right to left while the view is open?
Use a NSTimer. Move the UIImageView move everytime the timer ticks
09-18-2010, 07:16 AM
#3 (permalink )
Registered Member
Join Date: Aug 2010
Posts: 98
What's the code to move the image? I mean what do I put in the -(void) That the timer is calling?
09-18-2010, 09:01 AM
#4 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
Quote:
Originally Posted by
rTicker
What's the code to move the image? I mean what do I put in the -(void) That the timer is calling?
myImageView.frame = CGRectMake(myImageView.frame.origin.x, myImageView.frame.origin.y, myImageView.size.width, myImageView.size.height);
you must only increment the x, and when it is > Z, you will set to 0.
__________________
09-18-2010, 12:04 PM
#5 (permalink )
Registered Member
Join Date: Aug 2010
Posts: 98
I am getting an error: request for member 'size' in something not a structure or union
With this code put in a -(void) that a timer is calling. Please Help Me!
four.frame = CGRectMake(four.frame.origin.x, four.frame.origin.y, four.size.width, four.size.height);
09-18-2010, 12:07 PM
#6 (permalink )
iPhone SDK learner
Join Date: Feb 2010
Location: Illinois, USA
Posts: 421
Quote:
Originally Posted by
rTicker
I am getting an error: request for member 'size' in something not a structure or union
With this code put in a -(void) that a timer is calling. Please Help Me!
four.frame = CGRectMake(four.frame.origin.x, four.frame.origin.y, four.size.width, four.size.height);
UIImageViews do not have a property called 'size'. CGRect does though, so
Code:
four.frame = CGRectMake(four.frame.origin.x, four.frame.origin.y, four.frame. size.width, four.frame. size.height);[/quote]
09-18-2010, 12:56 PM
#7 (permalink )
Registered Member
Join Date: Oct 2008
Posts: 247
It's much easier to set up an animation block with SetAnimationRepeatCount = FLT_MAX. No NSTimer required!
Last edited by c0der; 09-18-2010 at 01:00 PM .
09-18-2010, 01:14 PM
#8 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
Quote:
Originally Posted by
Batman
UIImageViews do not have a property called 'size'. CGRect does though, so
Code:
four.frame = CGRectMake(four.frame.origin.x, four.frame.origin.y, four.frame. size.width, four.frame. size.height);
[/quote]
thanks, i wrote without checking
__________________
09-18-2010, 04:41 PM
#9 (permalink )
Registered Member
Join Date: Aug 2010
Posts: 98
I put the following codeine the -(void) that the timer calls. I got no errors but when I run the app it doesn't move a bit. I want it to go right to left.
four.frame = CGRectMake(four.frame.origin.x, four.frame.origin.y, four.frame.size.width, four.frame.size.height);
09-20-2010, 04:57 AM
#10 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
Quote:
Originally Posted by
rTicker
I put the following codeine the -(void) that the timer calls. I got no errors but when I run the app it doesn't move a bit. I want it to go right to left.
four.frame = CGRectMake(four.frame.origin.x, four.frame.origin.y, four.frame.size.width, four.frame.size.height);
mmm.....try to undestand what are you doing.
you are setting a new frame for you view, it consist of a X (you know what it represent no?) a Y, a width (that not must change), and a height (that not must change). So maybe if you set the x of something as the old x, you will not see nothing move.
__________________
09-20-2010, 12:32 PM
#11 (permalink )
I will be a billionaire.
Join Date: Sep 2009
Location: Scarborough, United Kingdom
Age: 17
Posts: 1,344
Let me google that for you
Wasn't that hard I don't think, there are tons of solutions. Videos from YouTube will probably be best. Most of them set the image moving across the whole screen. So you just need to set the coordinates to just go across the screen (or whatever you want).
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 305
15 members and 290 guests
2ndSegment , cayladv57 , cgokey , dermotos , djohnson , Domele , Hamad , heshiming , linkmx , markuschow , pungs , Sloshmonster , teebee74 , v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs