4

I have a tableview with frame size of(0, 65, 320, 503).When i navigate to another page then i come back it move down. Before navigate to another page

After navigate back from nextpage

user3823935
  • 891
  • 2
  • 16
  • 26
  • i added tableview storyboard itself... – user3823935 Dec 24 '14 at 04:40
  • I think you have given top constraints to table view from top layout guide. Try to uncheck under top bars property of view controller. – Ashish P. Dec 24 '14 at 05:12
  • @user3823935 I have the same issue you had. When I navigate back, the table, the table view already scrolled up. So I don't navigate back to the original selected row. – Sam Jan 14 '15 at 07:58

6 Answers6

3

add the below line in your - (void)viewDidLoad method.

self.automaticallyAdjustsScrollViewInsets = NO;

hope it will fix your issue.

Keshav
  • 2,965
  • 3
  • 25
  • 30
  • Setting automaticallyAdjustsScrollViewInsets to no would have the navigation bar covering the table view. It didn't work for me neither. – Sam Jan 14 '15 at 07:56
2

I hope you found a solution that worked for you. This was happening to me when using AutoLayout and UITableViews combined with the wonderful SWRevealViewController class. Long story short I wasted a bunch of time and eventually found this answer that worked for me:

https://stackoverflow.com/a/23021157/892990

I moved my UITableView to a lower position in the view hierarchy (by putting a dummy 1pt-thick spacer UIView between it and the Top Layout Guide), and now it behaves as expected.

Community
  • 1
  • 1
jperl
  • 1,066
  • 7
  • 14
0

Place this code in view will appear,

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
}
[self.navigationController.navigationBar setTranslucent:NO];

and also try removing auto layouts.

Hope this helps...

Saif
  • 2,678
  • 2
  • 22
  • 38
0

I think you need to set frame of tableview in viewWillAppear method again because some way in your code you r changing the frame so just set it in viewwillappear .

Shobhakar Tiwari
  • 7,862
  • 4
  • 36
  • 71
0

Try this in your viewWillAppear

[your_tableview removeFromSuperview];
[your_tableview setTranslatesAutoresizingMaskIntoConstraints:YES];
your_tableview.frame = CGRectMake(0, 65, 320, 503);
[self.view addSubview:your_tableview];

You could also try this if you don't want to use the header section

your_tableview.tableHeaderView = nil;
Mike S
  • 11,329
  • 6
  • 41
  • 76
0

if you are using storyboard.

1>set Navigation bar's translucent property to NO. Adjust your subviews frame again because after setting its NO ,the subview will be adjusting with some new frames.

2> In viewDidLoad set the following

self.automaticallyAdjustsScrollViewInsets = NO;

3> its done.

Chandramani
  • 871
  • 1
  • 12
  • 11