我正在爲iPad設計項目,我試圖通過切換預先呈現的圖像來模擬帶觸摸的3D身體的旋轉。優化在iPad上加載許多圖像
對於內存管理,我並不是最敏銳的人,所以我想知道是否有人有關於如何優化的提示。
我的解決方案,現在看起來是這樣的:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [[event allTouches] anyObject];
CGPoint location = [myTouch locationInView:self.view];
int pictureIndex;
//Rough mapping of image to point on screen
if (location.x <= 384) {
pictureIndex = (384 - location.x)/(768/rotatingPictures)+1;
}
else {
pictureIndex = rotatingPictures - (location.x-384)/(768/rotatingPictures)+1;
}
[theImageView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"image_%d.png", pictureIndex]]];
}
其高效加載圖像這樣?將圖像首先加載到數組還是更好?
我寧願一次加載所有加載時間,而不是在旋轉時加載。
是的,就像一個魅力。感謝大家的幫助。 – Jonatan 2010-11-11 13:56:31
對不起,我對這個網站的禮節沒有見識。我試圖現在投票,但得到一個消息,說我缺乏投票的聲望。如果你希望我做別的事情,請告訴我。 – Jonatan 2011-01-30 07:25:25