我有一個產品詳細信息屏幕,當用戶選擇產品的表格/網格視圖中顯示的產品之一時,它會滑入視圖。我使用CATransition向上滑動視圖,而不是使用presentModalViewController。UITableView在接收到內存警告並取消「模態」視圖後出現部分修剪(空白)
原因是因爲在詳細信息屏幕中,我允許用戶左右滑動瀏覽產品表並顯示相應的詳細信息。再次,幻燈片動畫是使用CATransition完成的。當我使用模態視圖呈現初始細節屏幕時,滑入的產品屏幕會出現旋轉並且行爲異常。我認爲它與在模態視圖中使用CATransition有關,因此我決定使用CATransition來顯示初始屏幕。下面是做幻燈片動畫代碼:
+(void)slideFromView:(UIView*)currentView toView:(UIView*)nextView direction(CCUISlideDirection)direction{
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];
// remove the current view and replace with the next view to display
[currentView removeFromSuperview];
[theWindow addSubview:nextView];
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
switch (direction) {
case CCUISlideLeft:
[animation setSubtype:kCATransitionFromRight];
break;
case CCUISlideRight:
[animation setSubtype:kCATransitionFromLeft];
break;
case CCUISlideUp:
[animation setSubtype:kCATransitionFromTop];
break;
case CCUISlideDown:
[animation setSubtype:kCATransitionFromBottom];
break;
default:
break;
}
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
}
現在所有的刷卡式視圖過渡做工精細,直到我收到一個內存警告。收到警告後,關閉屏幕上的詳細信息屏幕後,部分產品的表格/網格視圖會出現剪切。具體來說,表格右側的1/3左右顯示爲白色。見下面的截圖鏈接:
http://www.dropbox.com/gallery/19636498/1/work?h=4ecde7
而且,這裏是委託代碼駁回觀點:
-(IBAction)dismiss:(id)sender
{
MyWishesItemController* controller = (MyWishesItemController*)sender;
[CCUIHelper slideFromView:controller.currentView toView:self.view direction:CCUISlideDown];
if ([[_wishListResultsController fetchedObjects] count] > 0) {
[self showWishList];
}
else {
[self showEmptyList];
}
}
此外,當我在應用程序中選擇不同的選項卡式視圖,並回到談判桌看來,它顯得很好。對我而言,奇怪的是,它只是表格的一部分。當我收到警告時,我嘗試重新載入表格,但沒有奏效。我也通過儀器運行它來識別和修復一些泄漏。
除了清除didReceiveMemoryWarning方法中的某些緩存,並以其他方式最大限度地減少內存使用以避免警告,我該如何解決此問題。 任何建議將不勝感激。
你在didReceiveMemoryWarning中設置了什麼?請張貼一些代碼。如果可以,還張貼一些截圖。 – MishieMoo
感謝您的關注MishieMoo。我想發佈一個截圖,但我沒有足夠的聲望點:(在我的didReceiveMemoryWarning中,我基本清除了已經查看過的細節屏幕的緩存,然後調用超級警告方法。此緩存用於存儲已查看產品的視圖,所以如果用戶重新使用該產品,他們不需要重新創建。 – djilo
嗯......我們可以看看你有什麼代碼嗎?而且你可以隨時鏈接到圖片=)和你用來呈現/解僱的代碼那是滑動的視圖。 – MishieMoo