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.

- 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 Answers
add the below line in your - (void)viewDidLoad method.
self.automaticallyAdjustsScrollViewInsets = NO;
hope it will fix your issue.

- 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
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.
-
Thanks man! Exactly same issue I had, using SWReveal. Glad I got to this post! – Hyder Feb 20 '17 at 08:18
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...

- 2,678
- 2
- 22
- 38
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 .

- 7,862
- 4
- 36
- 71
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;

- 11,329
- 6
- 41
- 76
-
i added tableview storyboard itself..your code will work fine.i want to know why this happending? – user3823935 Dec 24 '14 at 07:54
-
If my code solves your problem, then the cause of the issue is autolayout. – Mike S Dec 24 '14 at 07:55
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.

- 871
- 1
- 12
- 11