問(wèn)題描述
我已關(guān)閉 Autolayout 并且 viewcontroller 嵌入在導(dǎo)航控制器中.我正在使用 Xcode 5,Storyboard.
I have turned off Autolayout and viewcontroller is embedded in navigation controller. I am using Xcode 5, Storyboard.
我不明白為什么它會(huì)從頂部留下空間.實(shí)際上,在故事板中,我將標(biāo)簽正好放在導(dǎo)航欄下方.但是當(dāng)我在模擬器上運(yùn)行它時(shí),它會(huì)從頂部留下空間.
I don't understand why is it leaving space from top. Actually in storyboard i have put my label exactly below navigation bar. But when i run it on simulator then it leaves space from top.
解決此問(wèn)題的一種巧妙方法
One of the hacky way to resolve this
-(void)viewWillLayoutSubviews
{
self.scrollViewMain.frame = CGRectMake(0, -70, 320, 800);
self.scrollViewMain.contentSize = CGSizeMake(320, 800);
}
但是我錯(cuò)過(guò)了一些非常簡(jiǎn)單的方法嗎?
推薦答案
在 Xcode 5 中,在 storyboard 中選擇你的控制器 > 在 Attribute Inspector 中禁用 Adjust Scroll View Insets還要檢查你是否設(shè)置了任何 contentInset
In Xcode 5, in storyboard select your controller > in Attribute Inspector disable Adjust Scroll View Insets Also check if you have set any contentInset
編輯:我附上了一張照片
這篇關(guān)于為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!