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

iOS - 使用故事板和自動(dòng)布局使 UIScrollView 居中

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

問(wèn)題描述

我正在使用故事板和自動(dòng)布局創(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.

在上圖中,我想將滾動(dòng)視圖保持在超級(jí)視圖的前沿和右側(cè)表格視圖的中間.我不希望滾動(dòng)視圖在 iPhone5 中增加其寬度.我嘗試了不同的約束組合,但我無(wú)法實(shí)現(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.

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

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

推薦答案

您需要通過(guò)在屏幕上添加一個(gè)額外的視圖來(lái)做到這一點(diǎn).

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

目前你有...

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

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

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 增長(zhǎng).

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)在,因?yàn)闈L動(dòng)視圖的超級(jí)視圖是間隔視圖,所以它將始終居中在表格視圖和其余空間之間.

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 - 使用故事板和自動(dòng)布局使 UIScrollView 居中的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

get index or tag value from imageview tap gesture(從 imageview 點(diǎn)擊手勢(shì)獲取索引或標(biāo)簽值)
UIScrollView not scrolling regardless of large contentSize(無(wú)論內(nèi)容大小如何,UIScrollView 都不會(huì)滾動(dòng))
Clean autorotation transitions in a paging UIScrollView(清除分頁(yè) UIScrollView 中的自動(dòng)旋轉(zhuǎn)轉(zhuǎn)換)
UIScrollView zooming with Auto Layout(UIScrollView 使用自動(dòng)布局縮放)
How to create an image from a UIView / UIScrollView(如何從 UIView/UIScrollView 創(chuàng)建圖像)
iOS/Swift - Hide/Show UITabBarController when scrolling down/up(iOS/Swift - 向下/向上滾動(dòng)時(shí)隱藏/顯示 UITabBarController)
主站蜘蛛池模板: 一区二区网站 | av香蕉| 成人在线免费av | 一区二区三区不卡视频 | 成人免费看片在线观看 | 亚洲 欧美 另类 综合 偷拍 | 一区二区三区四区精品 | 亚洲精品一区二区三 | 一级片久久 | 手机在线看片1024 | 精品精品 | 精品国产一二三区 | 蜜臀av性久久久久av蜜臀妖精 | 日韩精品一区二区视频 | 国产视频黄色 | 国产高清视频 | 久精品视频 | 日韩二三区| 日韩午夜精品 | 欧美视频一二三区 | 毛片一级片 | 免费午夜视频 | 伊人影院久久 | 狠狠艹狠狠干 | 中文字幕一区二区三区在线观看 | 夜夜操天天操 | 黄色片网站在线观看 | 久久久www成人免费精品 | 91成年人| 国产激情综合五月久久 | www.99色| 亚洲精品区 | 97在线播放 | 精品国产一二三 | 久久视频一区 | 欧美一区二区三区在线观看 | 日韩在线视频一区二区三区 | 日韩在线视频一区 | 免费毛片在线播放免费 | 中文在线观看视频 | 色播亚洲|