UITableView appears partially clipped (blanked out) after receiving memory warning and “modal” view dismissed
我有一个"产品详细信息"屏幕,当用户选择产品的表/网格视图中显示的产品之一时,该屏幕会向上滑动进入视图。我使用CATransition向上滑动视图,而不是使用presentModalViewController。
之所以这样,是因为在详细信息屏幕中,我允许用户向左/向右滑动以浏览产品表并显示相应的详细信息。同样,幻灯片动画是使用CATransition完成的。当我使用模式视图显示初始详细信息屏幕时,刷入的产品屏幕将显示为旋转状态且通常表现为奇怪。我认为这与在模式视图中使用CATransition有关,因此我决定使用CATransition来显示初始屏幕。以下是执行幻灯片动画的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | +(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
此外,这是关闭视图的委托代码:
1 2 3 4 5 6 7 8 9 10 11 | -(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]; } } |
此外,当我在应用程序中选择其他选项卡式视图并返回到表格视图时,它看起来还不错。对我来说奇怪的是,这只是表的一部分被清空了。收到警告后,我尝试重新加载表格,但这没有用。我也通过Instruments运行它来识别并修复一些泄漏。
除了清除didReceiveMemoryWarning方法中的某些缓存,以及最大程度地减少内存使用以避免警告之外,我应该怎么做才能解决此问题。
任何建议将不胜感激。
在tableview上检查自动调整大小。在出现内存警告后,请确保其调整大小正确。