1

enter image description here

enter image description here

I settled the scrollview and the image should be at the top. But when I pushed this view on navigation controller it adds some strange spacing at the top

            if let destination = self.storyboard?.instantiateViewControllerWithIdentifier(StoryboardNames.ItemDetailsView.rawValue) as? ItemDetailsViewConroller {
                destination.itemEntity = updatedItem
                self.navigationVC?.pushViewController(destination, animated: true)
            }

But, I'm opening this view from different navigation controllers. From first the sizing is correct (no spacing at the top), but from another I receive this strange bug. Does anyone know why this is caused?

Roman Volkov
  • 245
  • 1
  • 4
  • 12
  • Can you show the simulator screenshot? Also from storyboard select the ViewController having scrollView and from attribute inspector deselect the Adjust Scroll View Insets property. – Bharat Modi Jul 15 '16 at 11:04
  • Check this answer http://stackoverflow.com/a/38365491/6433023 – Nirav D Jul 15 '16 at 11:07
  • Possible duplicate of [White space at top of tableView embedded in a container view](http://stackoverflow.com/questions/38365355/white-space-at-top-of-tableview-embedded-in-a-container-view) – Bharat Modi Jul 15 '16 at 11:09
  • This quest has been answered here. https://stackoverflow.com/questions/48965485/why-does-xcode-add-space-for-a-top-bar – TechyGod Feb 26 '18 at 18:52
  • This question has already been answered. https://stackoverflow.com/questions/48965485/why-does-xcode-add-space-for-a-top-bar – TechyGod Feb 26 '18 at 18:53

3 Answers3

1

write this below line in your viewDidLoad method:

self.automaticallyAdjustsScrollViewInsets = false
Bhadresh Mulsaniya
  • 2,610
  • 1
  • 12
  • 25
0

Uncheck Scrollview insets in storyboard

enter image description here

Rajesh
  • 10,318
  • 16
  • 44
  • 64
0

This thing will be happening if and only if you are adding ScrollView or its subclass(tableview,collectionView,textview etc) at first position in viewController's main view. You can move it to second or any other position or solve by doing following thing:

select your viewcontroller, and see its layout attribute as shown in following image, here uncheck the "Adjust Scroll View Insets". This will stop adding 20 pixel space above.

Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81