0

我有一个产品详细信息屏幕,当用户选择产品的表格/网格视图中显示的产品之一时,它会滑入视图。我使用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方法中的某些缓存,并以其他方式最大限度地减少内存使用以避免警告,我该如何解决此问题。 任何建议将不胜感激。

+0

你在didReceiveMemoryWarning中设置了什么?请张贴一些代码。如果可以,还张贴一些截图。 – MishieMoo

+0

感谢您的关注MishieMoo。我想发布一个截图,但我没有足够的声望点:(在我的didReceiveMemoryWarning中,我基本清除了已经查看过的细节屏幕的缓存,然后调用超级警告方法。此缓存用于存储已查看产品的视图,所以如果用户重新使用该产品,他们不需要重新创建。 – djilo

+0

嗯......我们可以看看你有什么代码吗?而且你可以随时链接到图片=)和你用来呈现/解雇的代码那是滑动的视图。 – MishieMoo

回答

0

检查您的tableview的自动调整大小。确保内存警告后正确调整大小。

+0

再次感谢您花时间!你的方式发送良好的业力:) – djilo