Being new to iOS after the Swift programming language was announced, it was a pain for me to find a fix to why the ScrollView always places an extra space at the top of the child view even though I already placed constraints.

I mean, that is what constraints are for, right? Check the image below. The ScrollView has a background color that looks pink and orange while its child View has a white background.

ios_uiscrollview1

See the extra space at the top? I tried to set combinations of alignment and spacing constraints to no avail. I wasted almost a half day for this till I decided to try my luck looking in Google searches for a solution.

And the solution is?

adjust_scrollview_insets

  • Click your ViewController in the tree list on the left
  • Select the Attribute Inspector
  • Under the View Controller area, go to the label that says Layout : Adjust Scroll View Insets
  • Uncheck that and recompile.

Now the extra top space will disappear.

ios_uiscrollview2

 

Since I am still new to iOS, I do not understand the purpose of this option. There are constraints in the first place so what is this for? Regardless, to avoid this problem, this is the only solution that works without doing any coding.

This typically works in iOS7 and later. However, I read that in iOS6 it still leaves a gap. I have not tested this but you could try this option that user Anooj VM provided in the Stack Overflow forum.

The fix is to implement within the viewDidLoad() by adding this line of code:

 

It was bound to happen sooner or later. I guess volume conquers all. Google’s Android surged past Apple’s iPhone last quarter and is closing in on the Blackberry as the most popular smartphone platform in the United States, market tracking firm comScore said Monday.

According to comScore, 63.2 million Americans owned smartphones at the end of December, up 60 percent from a year earlier.

Blackberry maker Research in Motion was the US smartphone leader at the end of the fourth quarter with 31.6 percent of the market but its share fell from 37.3 percent the previous quarter, comScore said.

Google’s Android mobile operating system was next with a 28.7 percent of the smartphone market at the end of December, up from 21.4 percent at the end of September.

Apple was third with 25.0 percent of the market, down from 24.3 percent the previous quarter, according to comScore.

Microsoft software was running on 8.4 percent of the smartphones in the United States, down from 9.9 percent the previous quarter, comScore said, and Palm, which is owned by Hewlett-Packard, saw its market share slip to 3.7 percent from 4.2 percent the previous quarter.

Now, I wonder how this will pan out in other countries …

Related Posts Plugin for WordPress, Blogger...