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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 10-15-2010, 09:49 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 1
GaspardNv is on a distinguished road
Default Translate UIImageView

I have some code in which i need to translate an UIImageView from the top of an iPad screen to the bottom with one UIButton, then translate it back with an other UIButton using this very UIImageView

I've tried this code below (**) but each time i push the button, its create a new subview.
How can i get through with this?
Thx

(**)
- (void)viewDidLoad {
[super viewDidLoad];
myImage = [UIImage imageNamed:@"myImage.png"];
UIImageView *bmyView = [[UIImageView alloc] initWithImage:bmyImage];
myView.frame = CGRectMake(100, -740, 568, 790);
myView.opaque = NO;
[self.view addSubview:myView];

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(200, 0, 90, 30);
button.adjustsImageWhenHighlighted = NO;
button.opaque = NO;
[button setTitle:@"Out" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed ) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

}

-(void)buttonPressed {

double speed = 1 / round(random() % 100) + 1.0;

UIImageView *myView =[[UIImageView alloc] initWithImage:myImage];
myView.frame = CGRectMake(100, -740, 568, 790);
myView.opaque = NO;
[self.view addSubview:myView];


[UIView beginAnimations:nil context:myView];
[UIView setAnimationDuration: 2*speed ];

myView.frame = CGRectMake(100, 0, 568, 790);
myView.opaque = NO;

[UIView setAnimationDidStopSelector:@selector(onAnimationC omplete:finished:context];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];

}

- (void)onAnimationCompleteNSString *)animationID finishedNSNumber *)finished contextvoid *)context {

UIImageView *myView = context;
myView.frame = CGRectMake(100, 0, 568, 790);
myView.opaque = NO;
[self.view addSubview:myView];

[myView release];
}
GaspardNv is offline   Reply With Quote
Reply

Bookmarks

Tags
ipad & iphone, translation, uibutton, uiimageview

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
» Online Users: 348
7 members and 341 guests
Desert Diva, dre, hain, HemiMG, lendo, mottdog, oceanlablight
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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