0

I am using RATreeView in one of my app, but facing some weird issue with content Offset (pls correct me if I am wrong). Visited many threads over "SO" about the same but no luck.

I m having some checkbox in each cell of table view, there are n number of cells, lets say on first launch I have 20 cells visible, now I want to click other checkbox so I scrolled down and now if I clicked on last checkbox of TableView the contentOffset (y offset) gets changed and table scrolled to down. THIS ISSUE is only with iso 7 not with ios 6.

In viewDidLoad -

if([[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."][0] intValue] >= 7) 
{
    self.automaticallyAdjustsScrollViewInsets = NO;
} 

Inside chekboxClickAction - To reload the table This is what I tried -

//------Approach 1----->>

CGPoint offset = [[self treeView] contentOffset];
[self.treeView reloadData];
self.treeView.contentOffset = CGPointMake(offset.x, offset.y);

//------Approach 2----->>

CGPoint offset = [[self treeView] contentOffset];
[self.treeView reloadData];
[self.treeView setContentOffset:CGPointMake(0, offset.y)];
[self.treeView setContentInset:UIEdgeInsetsMake(0,0,0,0)];

But no luck.

Below are the scenarios mentioned in the image1 and Image2.

Screen 1

Screen 2

Any help will really be appreciated.

iLearner
  • 1,670
  • 2
  • 19
  • 45
  • I guess you should ask the `RATreeView`'s developer about it, if you have not figured out how his component works – or you can implement an own tree-view which you can control entirely. – holex Jul 18 '14 at 08:22

2 Answers2

0

Just had a similar issue and found this question.

It seems if I restore the contentSize too it scrolls back where it was before ( my items are constant however, the code needs some adjustments for dynamic stuff ).

CGPoint crtOffset = self.treeView.contentOffset;
CGSize beforeContentSize = self.treeView.contentSize;
[self.treeView reloadData];
for (RADataObject * item in self.items)
{
    [self.treeView expandRowForItem:item withRowAnimation:RATreeViewRowAnimationNone];
}

self.treeView.contentSize = beforeContentSize;
self.treeView.contentOffset = crtOffset;
Templar
  • 1,694
  • 1
  • 14
  • 32
0

You can try this work around to fix contentOffset reset on iOS7

[self performSelector:@selector(setContentOffset) withObject:nil afterDelay:0.0];
kakilangit
  • 1,340
  • 1
  • 11
  • 12