2
A
回答
1
假設你的UIImage是一個UIImageView和圖像的觀點是320×480大小...
你的動畫塊可以調用的方法是完成時。此方法重置您的UIImageView的位置,然後開始播放動畫。
動畫塊:
-(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];
}
回調:
(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
這是我寫我的代碼 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
對不起問簡單的問題,但即時通訊非常新的Xcode
是正確的做法
相關問題
- 1. 我怎樣才能在黑莓上垂直居中?
- 2. 我怎樣才能讓背景圖像垂直重複滾動?
- 3. 我怎樣才能減少divs之間的垂直空間
- 4. 我怎樣才能讓一個ListBoxItem的垂直拉伸
- 5. 我怎樣才能從DataGridView
- 6. 我怎樣才能從WP7
- 7. 我怎樣才能從Excel
- 8. 我怎樣才能從HBITMAP
- 9. 我怎樣才能得到
- 10. 我怎樣才能在一個div中垂直堆疊圖像
- 11. 我怎樣才能垂直居中flexslider圖像
- 12. 我怎樣才能讓垂直響應根據顯示
- 13. 我怎樣才能讓圖像不包含垂直空間?
- 14. 我怎樣才能連接垂直多個列在熊貓
- 15. 我怎樣才能讓這兩個div彼此垂直顯示?
- 16. ?我怎樣才能從雙軌道上
- 17. 我怎樣才能
- 18. iPhone - 我怎樣才能得到高度的UIImage
- 19. 我怎樣才能移動到另一個的UIViewController programaticlly
- 20. 我我怎樣才能從cheerio
- 21. 我怎樣才能縮小我的網頁,以適應移動
- 22. 我怎樣才能讓我的JS車移動?
- 23. 我怎樣才能讓我的南遷移到工作?
- 24. 我怎樣才能得到一個垂直列表來加載PDF的iFrame
- 25. 我怎樣才能得到在UL上下的長度爲
- 26. 我怎樣才能看到我上傳到Heroku的文件?
- 27. 我怎樣才能Screw.Unit上的Internet Explorer
- 28. 我怎樣才能下載使用C++
- 29. 我怎樣才能從通過DatagramSocket的
- 30. 我怎樣才能維護被移動到一個目錄下覆蓋同名
我有固定的錯誤,但是當我嘗試建立並運行代碼,即時得到一個空白屏幕..爲什麼會這樣? – sony 2010-12-14 17:44:11