久久久久久久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)
主站蜘蛛池模板: 亚洲在线一区二区三区 | 九一视频在线播放 | 欧美美女被c | 欧美一级欧美一级在线播放 | 亚洲成人av | 91视频一区| 毛片在线看看 | 久久99精品久久久久 | 成人免费网站www网站高清 | 天天天操 | 999精品网 | 亚洲一二三区av | 色男人的天堂 | 国产精品免费一区二区 | 国精产品一品二品国精在线观看 | 国产精品久久国产精品99 | 亚洲一区三区在线观看 | 欧美日韩亚洲国产 | 婷婷在线视频 | 欧美6一10sex性hd| 中文字幕乱码视频32 | 羞羞视频在线免费 | 日韩精品区 | 午夜国产在线 | 日韩免费一区二区 | 国产原创在线观看 | 超碰人人91 | 91麻豆精品国产91久久久久久 | 免费一级黄 | 国产日韩欧美激情 | 777777777亚洲妇女 | 国产一区二区三区在线 | 欧美日韩久久精品 | 午夜免费在线观看 | 成年人在线 | 国产福利在线播放麻豆 | 男人影音 | 国产不卡视频在线 | 国产视频福利在线观看 | 风间由美一区二区三区在线观看 | 久久一久久 |