2010-12-14 6 views

Antwort

1

helfen, Ihre UIImage ist eine Ansicht in einer UIImageView und das Bild Unter der Annahme, 320 x 480 Größe ...

Ihre Animation Block eine Methode aufrufen kann, wenn es abgeschlossen ist. Diese Methode setzt die Position Ihrer UIImageView zurück und startet dann die Animation.

Animations Block:

-(void)animate { 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:.3]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
    [UIView setAnimationBeginsFromCurrentState:YES]; 
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(myCallback:finished:context:)]; 

    CGRect frame = yourImageView.frame; 
    frame.origin = CGPointMake(0, 480); 
    yourImageView.frame = frame; 

    [UIView commitAnimations]; 

} 

Rückruf:

(void)myCallback:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 

    CGRect frame = yourImageView.frame; 
    frame.origin = CGPointMake(0, 0) 
    yourImageView.frame = frame; 
    [self animate]; 
} 
0

Dies ist, wie ich meinen Code schrieb moving.h

#import <UIKit/UIKit.h> 
@interface movingViewController : UIViewController{ 
UIImageView *imageView1; 
} 
@property (retain , nonatomic) UIImageView *imageView1; 
@end 

moving.m

#import "movingViewController.h" 
@synthesize imageView1; 
-(void) animate { 
[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:.3]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
[UIView setAnimationBeginsFromCurrentState:YES]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(myCallback:finished:context:)]; 

CGRect frame = imageView1.frame; 
frame.origin = CGPointMake(0, 480) 
imageView1.frame = frame; 

[UIView commitAnimations]; 
} 

- (void)viewDidLoad { 

    [super viewDidLoad]; 
} 


-(void)myCallback:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { 

CGRect frame = imageView1.frame; 
frame.origin = CGPointMake(0, 0) 
imageView1.frame = frame; 
[self animate]; 
} 

- (void)didReceiveMemoryWarning { 

    [super didReceiveMemoryWarning];} 
- (void)viewDidUnload {} 
- (void)dealloc { 
    [imageView1 dealloc]; 
    [imageView1 release]; 
    [super dealloc]; 
} 
@end 

Im sorry einfachen Fragen zu stellen, aber sehr neu in Xcode

ist, dass der richtige Weg

+0

Ich habe im, die Fehler behoben, aber wenn ich versuche, den Code, im immer einen leeren Bildschirm zu erstellen und auszuführen .. Warum passiert das? – sony

Verwandte Themen