久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

iOS - 使用故事板和自動布局使 UIScrollView 居中

iOS - Using storyboard and autolayout to center the UIScrollView(iOS - 使用故事板和自動布局使 UIScrollView 居中)
本文介紹了iOS - 使用故事板和自動布局使 UIScrollView 居中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用故事板和自動布局創(chuàng)建 iOS 應(yīng)用程序,以便它在 iPhone4 和 iPhone5 上都能正常工作.下面是我使用故事板創(chuàng)建的視圖的屏幕截圖.

I'm creating iOS app using story board and auto layout so that it will work good on both iPhone4 and iPhone5. Below is the screen shot of the view that I'm creating using story board.

在上圖中,我想將滾動視圖保持在超級視圖的前沿和右側(cè)表格視圖的中間.我不希望滾動視圖在 iPhone5 中增加其寬度.我嘗試了不同的約束組合,但我無法實現(xiàn).

In the above image, I want to keep the scroll view in the middle from leading edge of superview and the right table view. I dont want the scroll view to increase its width in iPhone5. I tried different combinations of constraints, but I couldn't achieve it.

有人可以建議我為滾動視圖設(shè)置哪些約束,以便它位于中心.

Can some suggest me what are all constraints that I've to set for scroll view so that it will be in center.

推薦答案

您需要通過在屏幕上添加一個額外的視圖來做到這一點.

You will need to do this by adding an additional view to the screen.

目前你有...

- UIView (main view)
    |
    | - scrollView
    | - tableView

你應(yīng)該把滾動視圖放在另一個像這樣的視圖中......

You should put the scroll view inside another view like this...

- UIView (main view)
    |
    | - UIView (spacer View)
    |    | - scrollView
    |
    | - tableView

現(xiàn)在你可以做的是有這些限制......

Now what you can do is have these constraints...

spacer view leading edge constraint to super view = 0
spacer view trailing edge to table view leading edge = 0
table view width = (whatever the width is)
table view trailing edge to super view = 0

這將布置 spacer view 和 table view 以便 spacer view 增長.

This will lay out the spacer view and the table view so that the spacer view will grow.

現(xiàn)在你需要添加...

scroll view width = x
scroll view height = y
scroll view centered vertically in super view
scroll view centered horizontally in super view.

現(xiàn)在,因為滾動視圖的超級視圖是間隔視圖,所以它將始終居中在表格視圖和其余空間之間.

Now, because the scroll view's super view is the spacer view then it will always be centered in between the table view and the rest of the space.

這篇關(guān)于iOS - 使用故事板和自動布局使 UIScrollView 居中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

get index or tag value from imageview tap gesture(從 imageview 點擊手勢獲取索引或標簽值)
UIScrollView not scrolling regardless of large contentSize(無論內(nèi)容大小如何,UIScrollView 都不會滾動)
Clean autorotation transitions in a paging UIScrollView(清除分頁 UIScrollView 中的自動旋轉(zhuǎn)轉(zhuǎn)換)
UIScrollView zooming with Auto Layout(UIScrollView 使用自動布局縮放)
How to create an image from a UIView / UIScrollView(如何從 UIView/UIScrollView 創(chuàng)建圖像)
iOS/Swift - Hide/Show UITabBarController when scrolling down/up(iOS/Swift - 向下/向上滾動時隱藏/顯示 UITabBarController)
主站蜘蛛池模板: 在线一区视频 | www.天堂av.com | 一区二区三区电影网 | 一区二区国产精品 | 91看片网 | 欧美另类视频 | av手机在线播放 | 91精品国产777在线观看 | 一二三在线视频 | 日本精品视频在线观看 | 99视频免费播放 | 亚洲欧美日本在线 | 国产三级一区二区三区 | 一区精品国产欧美在线 | 涩涩导航 | av影音资源 | 中文字幕 在线观看 | 成人午夜精品 | 嫩草视频在线 | 精品欧美黑人一区二区三区 | 国产在线麻豆精品入口 | 亚洲一区免费视频 | 成人黄色在线 | www国产成人免费观看视频,深夜成人网 | 99精品欧美一区二区三区 | av片免费观看 | 懂色av蜜桃av | 久久亚洲精品国产精品紫薇 | 一区观看 | 免费黄色的视频 | 极情综合网| 日韩欧美国产精品一区 | 偷拍亚洲色图 | 99视频在线免费观看 | 中文亚洲视频 | 成在线人视频免费视频 | 日韩成人免费在线视频 | 亚洲一区中文字幕 | 亚洲男人天堂 | 久草免费电影 | 国产精品久久久久久久久久了 |