我在這個初學者:)IPhone應用程序崩潰的設備,但工程對iPhone
我有一個應用程序,它改變時,按下一個按鈕一個UIImageView的圖像,每幅圖像約爲200 KB,在運行時在模擬器中運行正常,我可以多次更換圖像而不會出現問題。
在我的設備上運行時(ipod touch)它加載正常,它緩慢地通過約4張圖像,然後崩潰。當我使用Allocations性能工具運行它時,它會在總字節數達到2.75 megs時崩潰。生活分配的數量大約是8000(這是高嗎?)。
我的控制檯讀取該
Program received signal: 「0」.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")
我使用「泄漏」性能工具也嘗試過,並沒有發現任何泄漏。
我.h文件中加載圖像和uimageview這樣的:
@property(retain, nonatomic) IBOutlet UIImageView* myUIImageView;
@property(nonatomic, retain) UIImage *image;
另外,我釋放這些是這樣的:
- (void)dealloc {
[super dealloc];
[myUIImageView release];
[image release];
}
我還添加了這一點,但它似乎沒有有什麼區別:
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
[myUIImageView release];
[image release];
// Release any cached data, images, etc that aren't in use.
}
我不知道還有什麼要嘗試在這一點上,任何調試技巧的建議會不勝感激,如何解決像這樣的內存問題的任何指針將非常有幫助, 謝謝!
此外,對不起忘了加上形象改變代碼:
- (IBAction)myButton {
static NSUInteger counter = 0;
counter++;
if (counter == 1) {
myUIImageView.image = [UIImage imageNamed:@"image1.jpg"];
}
else {
myUIImageView.image = [UIImage imageNamed:@"image2.jpg"];
counter = 0;
}
}
謝謝你的幫助喬希,我在我的圖像改變代碼中添加 – 2010-10-08 23:47:33
修改我的答案作爲迴應。;-) – 2010-10-08 23:51:17
嗯,我不太確定如果我使用伊娃,我在我的.m文件頂部合成圖像:@synthesize image;因爲它警告我即使它正在編譯也不存在,我也應該將myUIImageView設置爲didReceiveMemoryWarning中的nil以及圖像嗎?或者可以在這裏發佈它。 – 2010-10-08 23:55:59