4

I have an app with a UITableView which is fed data through an NSFetchedResultsController. The table view is sorted alphabetically and divided into sections by first letter.

When upgrading to iOS 7 on my phone, I have noticed that the section index titles does not work properly:

Action: Tap section index title "M" to scroll list to items starting with the letter M.

Expected results: Table view scrolls to first item in section M, section header remains visible.

Actual results: Table view scrolls to second item in section M, section header is not visible. The first item exists, but is just above the visible box.

On iOS 6, it all works as expected.

On a side note, the rubber banding effect above the top row and below the bottom row has a strange behavior as well, by 'stretching' the rubber band, I can see the first row, but as soon as I release it, the first row scrolls offscreen again. Likewise for the bottom row.

Updates

This is most likely caused by migrating from Xcode 4.6 Auto-layout to Xcode 5 Auto-layout, which I hear are not compatible. Maybe some constraint gone bad? I'm still struggling to find the cause of it.

The scene in Interface Builder consists of a UIView that contains two subviews -- two UITableViews that lay on top of eachother. Which of the two views that is visible is toggled through a UISegmentedControl on top in the nav bar. On the bottom there is a tab bar.

I have laid out interface manually in IB so that they all are fullscreen, this is done individually, i.e. no constraint specify same width/height, etc. The constraints I use have been none; suggested contraints by Autolayout; and I have also tried making contentInsets on both tableviews, as suggested by @duci9y.

The nav bar is set to non-transparent as suggested by @Popara.

End note

If I could understand how set the tableviews to be full screen except to shrink to make sure they don't underlap the navbar and tab bar.

Frost
  • 638
  • 5
  • 20
  • check the 'Content Insets' of your tableview. Are they messed up somehow; have a negative value? – fguchelaar Dec 05 '13 at 13:27
  • No, not doing anything with the contentInsets, but you tipped me into the direction of Autolayout, which seems like a much better point to investigate than my subclassing. – Frost Dec 05 '13 at 14:10
  • How are you setting the frame and constraints of the table view? And what constraints have you applied? – Wain Dec 10 '13 at 23:41
  • I've updated the question with info on how the frame is set (in IB manually) and what constraints I've tried. – Frost Dec 12 '13 at 08:07
  • This Post might be helpful for you. See Question and accepted answer. – AsifHabib Dec 12 '13 at 12:56

6 Answers6

2

This doesn't sound like an autolayout issue to me. In the view controller containing the table view, run self.automaticallyAdjustsScrollViewInsets = YES; in viewDidLoad.

Is the table view controller pushed on a navigation controller? Then that should be all you need to do.

If not, you need to read up on the properties edgesForExtendedLayout and topLayoutGuide. The latter is what you need to override if your view controller contains its own navigation bar.

topLayoutGuide tells your view controller how much top content inset any scroll views should have (this applies to table views since they inherit from scroll views). Since on iOS7, your table view goes behind the navigation bar (since it's translucent) its top layout guide must be set to be just below the navigation bar.

If your view hierarchy is more complicated (table view is not a direct subview of the view controller view), then you can set the content inset manually:

tableView.contentInset = UIEdgeInsetsMake(CGRectGetMaxY(navigationBar.frame), 0, 0, 0);
Accatyyc
  • 5,798
  • 4
  • 36
  • 51
  • This did not completely solve the problem (I can't get the top inset to align just right -- it's off by about the height of the status bar), but was the most helpful and got me the farthest distance. – Frost Dec 12 '13 at 21:07
  • Yes, the status bar is accounted for when using topLayoutGuide, however when doing it the manual way you could do this instead: CGRectGetMaxY(navigationBar.frame) – Accatyyc Dec 16 '13 at 13:58
1

set your tableview frame delta y to 20 in iOS 7

try this.

Aklesh Rathaur
  • 1,837
  • 18
  • 19
1

in ios7 y-axis start from top it may be navigation bar is there or not if you wants your y-axis start from below navigation bar (y-axis==0 after navigation bar ) you have to some coding in -viwDidLoad method like:-

- (void)viewDidLoad
{
    [super viewDidLoad];
    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;
    //here your initilization for table and others starts
}
1

Main UI difference in iOS 6 and iOS 7 is that status bar is included inside the viewcontroller in iOS 7. it means your view controller is 20 px greater than iOS6. you have to adjust your items. First design your items according to iOS 6 which is better way and you must have a lot of practice of doing that, now set Δy to 20 for every item.

Or design your items according to iOS 7 and set Δy to -20

See this Post for further details.

Community
  • 1
  • 1
AsifHabib
  • 944
  • 9
  • 25
0

Yes this is AutoLayout transition issue.

It seems that positioning of the table view bounds is not right.

In iOS7 View Controllers are positioned beneath the navigation bar, namely sharing the same starting view point (0,0), so the first cell is covered by navigation bar + section header.

More preferable path would be to set that your navigation bar is not translucent (probably via appearance proxy). The other option, to somehow offset your tableview for navigation bar height delta, either in loadView or viewDidLoad.

Best of luck.

Popara
  • 4,280
  • 2
  • 19
  • 19
0

Assuming your table view is in a controller within a Navigation controller/Tab bar controller hierarchy:

self.tableView.contentInset = UIEdgeInsetsMake(self.topLayoutGuide.length, 0, self.bottomLayoutGuide.length, 0);

duci9y
  • 4,128
  • 3
  • 26
  • 42