問題描述
我在情節(jié)提要中創(chuàng)建了一個 UIScrollView,將其作為屬性鏈接到視圖控制器,現(xiàn)在我正在嘗試添加一些帶有分頁的子視圖.但是,即使我以圖形方式在情節(jié)提要中設(shè)置了尺寸,UIScrollView 的框架最終還是 0,0,0,0.即使我已經(jīng)在情節(jié)提要中以圖形方式指定了尺寸,是否還需要對尺寸進(jìn)行硬編碼?
I created a UIScrollView in the storyboard, linked it as a property to the view controller, and am now trying to add some subviews with pagination. But, even though I set the dimensions in the storyboard graphically, the frame of the UIScrollView ends up being 0,0,0,0. Am I required to hardcode the dimensions even though I already specified them graphically in the storyboard?
另外,有點(diǎn)相關(guān),是否可以自定義故事板中的子視圖以在此滾動視圖中使用?除非它已經(jīng)在控制器中,否則我似乎無法創(chuàng)建這樣的視圖.由于我只有一個控制器,并且可能有多個視圖,我想以圖形方式設(shè)置,我該如何做到這一點(diǎn)而不必以編程方式進(jìn)行?
Also, kind of related, is it possible to customize subviews in the storyboard to use in this scroll view? It seems that I cannot create such a view unless it is already within a controller. Since I only have one controller and potentially multiple views I want to set up graphically, how do I do this without having to do so programmatically?
推薦答案
使用故事板 viewDidLayoutSubviews 是您可以獲取所有視圖大小的地方.viewWillAppear 對我不起作用,總是返回 (0,0,0,0);
With storyboards viewDidLayoutSubviews is where you can get the size of all your views. viewWillAppear did not work for me and always returned (0,0,0,0);
這篇關(guān)于在使用幀 0,0,0,0 初始化的故事板中創(chuàng)建的 ScrollView的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!