开发者

UITableView appears partially clipped (blanked out) after receiving memory warning and "modal" view dismissed

I have a product details screen that slides up into view when a user selects one of the products displayed in a table/grid view of products. I use CATransition to slide the view up, rather than use presentModalViewController.

The reason for this is because in the details screen, I allow the user to swipe left/right to navigate through the table of products and display the corresponding details. Again, the slide animation is done using CATransition. When I used a modal view to present the initial details screen, the swiped-in product screen would appear rotated an开发者_StackOverflowd generally behave oddly. I assumed it had something to do with using CATransition within a modal view, so I decided to use CATransition to present the initial screen. Here is the code that does the slide animation:

+(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"];
}

Now all the swiped-in view transitions work fine, until I receive a memory warning. After I receive the warning, and then dismiss/slide the details screen offscreen, part of the table/grid view of products appears clipped. Specifically, about 1/3 of the right side of the table appears white. See screenshot link below:

http://www.dropbox.com/gallery/19636498/1/work?h=4ecde7

Also, here is the delegate code to dismiss the view:

-(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];
  }
}

Also, when I select a different tabbed view in the application and return to the table view, it appears fine. The odd thing to me is that it is only a part of the table that is blanked out. I've tried reloading the table when I receive the warning, but that didn't work. I've also run it through Instruments to identify and fix some leaks.

Other than clearing some caches in the didReceiveMemoryWarning method, and otherwise minimizing memory usage to avoid the warnings, what should I be doing to fix this problem. Any suggestions would be greatly appreciated.


Check the autosizing on your tableview. Make sure it is resizing correctly after the memory warning.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜